August 6, 2009 at 7:55 am
Hi,
I need to write a SQL Query.
I have the following tables:
tblEmployee
---------------------------
IDName GroupNumber
---------------------------
1Jack1
2John3
3Sally4
4Susan4
5Ned6
tblGroupNumber
--------------------------------
IDGroupNumberManager Name
--------------------------------
11James Bond
21Gi Joe
31Sally Bond
42John Lennon
52George Harrison
63Ringo Starr
73Paul McCartney
83Roger Waters
93Phil Collins
10 4Madonna
11 5 Britney Spears
12 6 Jolly Rogers
12 6Mad Max
12 6Nirvana
The result I seek is that for each employee (from the first table),
I need to return all their manager's names. Tie tblEmployee and tblGroupNumber on the GroupNumber column.
The result should look like this:
------------------------------------------------------------------------------------------
IDName GroupNumberManagerName ManagerNameManagerName ManagerName
------------------------------------------------------------------------------------------
1Jack 1James Bond Gi JoeSally Bond----
2John3Ringo StarrPaul McCartneyRoger WatersPhil Collins
3Sally4Madonna------------
4Susan4Madonna------------
5Ned6Jolly RogersMad MaxNirvana----
August 6, 2009 at 8:27 am
We'd like to see you make an attempt. Basically you are attempting a cross tab, so if you search for help there, that might work for you. Or look at the PIVOT command.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply