Forum Stats

  • 3,874,089 Users
  • 2,266,676 Discussions
  • 7,911,721 Comments

Discussions

If select query fetches 2 records with 3 columns. I want to make a query which will give output in o

2999661
2999661 Member Posts: 1
edited Jul 27, 2015 3:23PM in SQL & PL/SQL

For example.

My Table gives following records.

ServiceSubServiceAddresss
11_AAAASD
11_BBBRTY
22_RRRTYT
22_YYYGHN

For each main service I want both the SubService and Address on the same row.

Output expected

ServiceSubservice1Address1SubService2Address2
11_AAAASD1_BBBRTY
21_BBBTYT2_YYYGHN

Please help

Tagged:

Answers

  • Frank Kulash
    Frank Kulash Member, Moderator Posts: 42,745 Red Diamond
    edited Jul 27, 2015 3:23PM

    Hi,

    That's called Pivoting, and the Forum FAQ has a page devoted to it:

    If you get stuck, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements), the exact results you want from that data, and an explanation of how you get the results from that data.

    See this Forum FAQ page:

This discussion has been closed.