Home » SQL & PL/SQL » SQL & PL/SQL » How to convert rows into column (2 Merged) (10g and 11.2g)
How to convert rows into column (2 Merged) [message #567253] Tue, 25 September 2012 12:12 Go to next message
Messages: 1
Registered: September 2012
Junior Member
How to convert station & date wise multiple rows to date wise coloumn
I have a table TEST like this,

STN_Name Date State
DELHI 1-Sep-201 G
DELHI 2-Sep-201 B
DELHI 3-Sep-201 G
DELHI 4-Sep-201 G
DELHI 5-Sep-201 G
DELHI 6-Sep-201 M
DELHI 7-Sep-201 G
DELHI 8-Sep-201 G
DELHI 9-Sep-201 G
DELHI ......... ..
DELHI 30 Sep 2012 G
KOLKATA 1-Sep-201 G
KOLKATA 2-Sep-201 B
KOLKATA 3-Sep-201 B
KOLKATA 4-Sep-201 B
KOLKATA 5-Sep-201 G
KOLKATA 6-Sep-201 M
KOLKATA 7-Sep-201 G
KOLKATA 8-Sep-201 G
KOLKATA 9-Sep-201 B

I want output like this

STN_Name 1-Sep-2012 2-Sep-2012 3-Sep-2012 4-Sep-2012 5-Sep-2012 ............Sep 2012

Please help me with suitable SQL query in 10G or above
Re: How to convert rows into coloumn [message #567256 is a reply to message #567253] Tue, 25 September 2012 12:26 Go to previous messageGo to next message
Messages: 25574
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:


PIVOT by Frank http://forums.oracle.com/forums/message.jspa?messageID=3227306
PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?
Re: How to convert rows into column (2 Merged) [message #567261 is a reply to message #567253] Tue, 25 September 2012 12:39 Go to previous message
Michel Cadot
Messages: 65146
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Welcome to the forum.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, Post a working Test case: create table 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.

In the end, search before any post, this question is a FAQ.

Previous Topic: In an update on a table, is trigger fired before control returns to the procedure ?
Next Topic: can I select count(*) from v_table (dynamic table)?
Goto Forum:

Current Time: Mon Aug 21 03:35:17 CDT 2017

Total time taken to generate the page: 0.01552 seconds