Home » SQL & PL/SQL » SQL & PL/SQL » Trying to query multiple rows into multiple columns (Oracle 10)
Trying to query multiple rows into multiple columns [message #340876] Thu, 14 August 2008 14:32 Go to next message
klkuab
Messages: 25
Registered: November 2007
Junior Member
I am trying to convert data from multiple rows into multiple columns. Let me see if I can paint the picture for you.

Here is a sample of the table i am trying to read from:

Company Name Account
1 Sam 123
1 Sam 234
1 Joe 345
1 Sue 789
1 Sue 987
1 Sue 573

I am trying to put this into a View that would have the data represented as such:

Company Name Acct1 Acct2 Acct3 Acct4
1 Sam 123 234 <null> <null>
1 Joe 345 <null> <null> <null>
1 Sue 789 987 573 <null>

Many thanks in advance for your help!
Re: Trying to query multiple rows into multiple columns [message #340878 is a reply to message #340876] Thu, 14 August 2008 14:37 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & follow posting guidelines as stated in URL above


Search this forum for "pivot" as this question is asked almost daily.
Re: Trying to query multiple rows into multiple columns [message #341376 is a reply to message #340876] Mon, 18 August 2008 11:03 Go to previous message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
try these

Kevin Meade's blog

Example of Data Pivots in SQL (rows to columns and columns to rows)

Good luck, Kevin
Previous Topic: Interval to Seconds
Next Topic: no rows
Goto Forum:
  


Current Time: Tue Dec 03 08:41:59 CST 2024