Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with query!!!

Status
Not open for further replies.

danvzla

Programmer
Jan 16, 2004
28
FI
Hi All.

I need help on crating a Query that from this table:


Name ! Project ! Area ! Jan ! Feb ! Mar !
---------------------------------------------
John ! A ! Boston ! 1 ! 1 ! 0 !
Peter ! B ! NY ! 0 ! 1 ! 1 !
Paul ! C ! NJ ! 0 ! 0 ! 1 !
John ! D ! PA ! 0 ! 0 ! 1 !
Peter ! E ! Miami ! 1 ! 0 ! 0 !
Paul ! D ! PA ! 1 ! 1 ! 0 !

Gives this result (query result):

! Jan ! Feb ! Mar !
Name ! Project! Area ! Project! Area ! Project ! Area!
-------------------------------------------------------
John ! A ! Boston! A ! Boston! D ! PA !
Peter ! E ! Miami ! B ! NY ! B ! NY !
Paul ! D ! PA ! D ! PA ! C ! NJ !


Can anybody give me a hand on the SQL that I need for generating this query

Thanks

Dan


 
Typed, untested:
SELECT J.Name, J.Project AS JanProject, J.Area AS JanArea
, F.Project AS FebProject, F.Area AS FebArea
, M.Project AS MarProject, M.Area AS MarArea
FROM (yourTable AS J
INNER JOIN yourTable AS F ON J.Name = F.Name)
INNER JOIN yourTable AS M ON J.Name = M.Name
WHERE J.Jan = 1 AND F.Feb = 1 AND M.Mar = 1;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top