Home » SQL & PL/SQL » SQL & PL/SQL » how do I produce columns based on values within a column
how do I produce columns based on values within a column [message #633129] Wed, 11 February 2015 07:14 Go to next message
Mr CPT
Messages: 1
Registered: February 2015
Junior Member
A very basic question...how do I produce columns based on values within a column
I have a table like this

Ref Name type Name
001 Firstname Jim
001 Firstname Ali
001 Surname Jones
002 Firstname Stan
002 Surname Smith
003 NULL Barack

and want to run a query to produce the following result

Ref Firstname Surname
001 Jim Jones
001 Ali Jones
002 Stan Smith
003 NULL Barack
Re: how do I produce columns based on values within a column [message #633130 is a reply to message #633129] Wed, 11 February 2015 07:16 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: how do I produce columns based on values within a column [message #633132 is a reply to message #633129] Wed, 11 February 2015 07:25 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This is a standard PIVOT question (search for this term).

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.

Previous Topic: Oracles recursive Connect By
Next Topic: Spliting of String
Goto Forum:
  


Current Time: Wed Apr 24 10:35:47 CDT 2024