Home » SQL & PL/SQL » SQL & PL/SQL » Row to Column
Row to Column [message #348110] Mon, 15 September 2008 12:13 Go to next message
kvignes1
Messages: 33
Registered: September 2007
Member

Hi

Need help in the following one.

SQL> desc lookup
Name
--------------------
MT_MODELNAME
MT_ID

SQL> desc input
Name
--------------------
MT_MODELNUMBER
MT_REPLACEDBYID

SQL> select * from lookup;

M MT_ID
- ----------
A 101

SQL> select * from input;

MT_MODELNUMBER MT_REPLACEDBYID
-------------- ---------------
1 101
2 101
3 101


I want my output like this A,1,2,3 when I compare lookup.MT_ID=input.MT_REPLACEDBYID

I know we can do it by writing a used defined function, but just want to know whether we can do it in a single query?





Re: Row to Column [message #348111 is a reply to message #348110] Mon, 15 September 2008 12:15 Go to previous messageGo to next message
BlackSwan
Messages: 25050
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

>just want to know whether we can do it in a single query?
We?
I don't know about you.
I do know that I can do it.

Search this forum for "pivot query".
Re: Row to Column [message #348113 is a reply to message #348110] Mon, 15 September 2008 12:23 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals) and search BEFORE posting.

Regards
Michel
Previous Topic: How to generate random positive numbers?
Next Topic: is it the right query !
Goto Forum:
  


Current Time: Sun Dec 11 08:18:18 CST 2016

Total time taken to generate the page: 0.17593 seconds