Home » SQL & PL/SQL » SQL & PL/SQL » Select Rows as Columns (Oracle 9.2)
Select Rows as Columns [message #359592] Mon, 17 November 2008 08:45 Go to next message
Deon Smit
Messages: 36
Registered: September 2008
Member
Hi all. This is my normal query.


select * from baandb.ttdinv750700
order by T$ITEM

I get. For Example the following.

Item Year Month1 Month2 Month3
---------------------------------------------
abc 2005 1 22 4
abc 2006 45 64 4
abc 2007 99 46 99
bbc 2005 54 64 4
bbc 2006 2 4 77
bbc 2007 46 7 98


I want my records to be returned as follow as possible.

Item | 2005 Month1 | 2005 Month2 | 2005 Month3 | 2006 Month1 | 2006 Month2 |
abc | 1 | 22 | 4 | 45 | 64
bbc | 54 | 64 | 4 | 2 | 4


Please Guide me to get this working.
Re: Select Rows as Columns [message #359594 is a reply to message #359592] Mon, 17 November 2008 08:59 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Please search for the Term 'PIVOT' there are several examples to help you along the way. Please also take the time to read the OraFAQ posting guidelines as your post has 'broken' many of those guidelines that are set down to assist you.
Thanks
Re: Select Rows as Columns [message #359674 is a reply to message #359592] Tue, 18 November 2008 00:02 Go to previous message
Deon Smit
Messages: 36
Registered: September 2008
Member
Thank you I will do.

Regards
Previous Topic: Embedded SELECT statements
Next Topic: Find No Of Days Between Two Dates
Goto Forum:
  


Current Time: Sun Dec 04 08:53:53 CST 2016

Total time taken to generate the page: 0.09104 seconds