Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combining column values across rows with sorting

0 views
Skip to first unread message

puneet

unread,
Jun 12, 2006, 7:49:51 AM6/12/06
to
Hi,
I'm absolutely new to oracle & have been asked to write a query which
combines multiple columns into a single row.I'm sure that this can be
done using 9i but havent been able to figure out how.
The table is:

Emp ID Code Name
1 d ddd
1 b bbb
1 c ccc
1 a aaa
2 p ppp
2 z zzz
2 a aaa

Req o/p using a query is:

Emp ID Details(sorted according to Code before
concatenation)
1 aaa,bbb,ccc,ddd
2 aaa,ppp,zzz

I'll highly appeciate it if anyone can tell me the query to get this
result.
Thanks.

Mark D Powell

unread,
Jun 12, 2006, 9:14:18 AM6/12/06
to

A simple quiery with an order by on emp_id, code will arrange the data
in the right order then all you have to do is pivot the rows into
columns. Actually concatenate in your case.

See the newsgroup archives searching on pivot table.
Or visit http://asktom.oracle.com and search on the same subject.

HTH -- Mark D Powell --

DA Morgan

unread,
Jun 12, 2006, 11:46:12 AM6/12/06
to

www.psoug.org
Click on Morgan's Library
Click on DECODE
--
Daniel A. Morgan
University of Washington
damo...@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

0 new messages