Home » SQL & PL/SQL » SQL & PL/SQL » rows as columns
rows as columns [message #255405] Tue, 31 July 2007 13:03 Go to next message
Duke
Messages: 14
Registered: August 2006
Junior Member
I have got a new challenge....
I am trying to get an extra field in a select as below, empindep, which should contain all the empno concatinated who are in the same department number, not only for department 20 but for all departments, anybody know how to do this?


select emp.empno,emp.deptno, (select dummy from dual) as empindep from scott.EMP emp;

EMPNO DEPTNO EMPINDEP
---------------------- ---------------------- --------
7369 20 7369,7876,7902,7566,7788
7499 30 X
7521 30 X
7566 20 7369,7876,7902,7566,7788
7654 30 X
7698 30 X
7782 10 X
7788 20 7369,7876,7902,7566,7788
7839 10 X
7844 30 X
7876 20 7369,7876,7902,7566,7788
7900 30 X
7902 20 7369,7876,7902,7566,7788
7934 10 X
Re: rows as columns [message #255406 is a reply to message #255405] Tue, 31 July 2007 13:11 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
search "PIVOT QUERY"
Re: rows as columns [message #255407 is a reply to message #255405] Tue, 31 July 2007 13:33 Go to previous message
Duke
Messages: 14
Registered: August 2006
Junior Member
@anacedent, thank you very much, the solution is to know what to search for.... your help was very much appreciated.

A solution: http://www.orafaq.com/forum/t/12183/0/
Previous Topic: Question on duplicates
Next Topic: how to get top 3 salaries for each dept
Goto Forum:
  


Current Time: Sat Dec 10 22:41:31 CST 2016

Total time taken to generate the page: 0.11081 seconds