Home » SQL & PL/SQL » SQL & PL/SQL » Transpose/Pivot with all combination
Transpose/Pivot with all combination [message #637237] Wed, 13 May 2015 07:27 Go to next message
jjxxs
Messages: 1
Registered: May 2015
Junior Member

Hi,Could u pls help on the following scenario. I need to transpose a table with the following content:

COL_A COL_B COL_C
544 D1 268
544 D1 269
544 D2 1
544 D3 69
544 D3 70
To the following:

COL_A D1 D2 D3
544 268 1 69
544 268 1 70
544 269 1 69
544 269 1 70
So, for each unique occurrence of COL_A, each unique value in COL_B is to be a column, and all permutations of COL_B, COL_C are to be transposed. For example if there were 5 rows of D1, 2 rows of D2, 3 Rows of D3 and 2 rows of D4
Re: Transpose/Pivot with all combination [message #637247 is a reply to message #637237] Wed, 13 May 2015 07:51 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/
Re: Transpose/Pivot with all combination [message #637251 is a reply to message #637237] Wed, 13 May 2015 08:20 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result (align the columns in result).

Previous Topic: CREATE ANY PACKAGE alternative
Next Topic: To take Previous date
Goto Forum:
  


Current Time: Thu Apr 25 12:29:03 CDT 2024