Home » SQL & PL/SQL » SQL & PL/SQL » Formatting a SQL Query
Formatting a SQL Query [message #301839] Thu, 21 February 2008 23:55 Go to next message
saharookiedba
Messages: 56
Registered: September 2007
Location: PUNE
Member
Hi,

I have written a sql query that fetches data from two tables
1)dept :- Parent
2)emp :- Child

E.g A dept 10 can have many employees under it.

now if for a record for 10 in dept there are 3 records in emp...
my Query :

select dept.name, dept.Location, emp.Ename
from dept, emp
where dept.deptno = emp.deptno
and dept.deptno = 10;


I will get three records like

e.g Purchase Newyork lewis
Purchase Newyork george
Purchase Newyork peter


my question is can i combine these three records into one $ then display like,

Purchase Newyork lewis,george,peter..

using a only a sql query...

Thanking in advance....

Re: Formatting a SQL Query [message #301840 is a reply to message #301839] Fri, 22 February 2008 00:01 Go to previous message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
search for PIVOT.


regards,
Previous Topic: Dynamic SQL
Next Topic: Encryption (merged)
Goto Forum:
  


Current Time: Thu Dec 08 10:18:22 CST 2016

Total time taken to generate the page: 0.05197 seconds