Question : SQL Query for report

I have 2 tables

Timesheet
   StaffID
   ProjectID
   Time

Staffnames
   StaffID
   Name


I want to have a query that displays the following.  Bearing in mind that staff mebers may not work on all projects (or any if they are new)  but i still need them to appear (with a 0)
         
                                  TIME
                    Project 1       Project   2
John                   3                  4
Kevin                  23                0
Steve                  0                  41

Answer : SQL Query for report

this should do:
1:
2:
3:
4:
5:
6:
7:
select s.Name
 , sum(case when t.ProjectID = 1 then t.Time end ) Project1
 , sum(case when t.ProjectID = 2 then t.Time end ) Project2
 from StaffNames s
 left join Timesheet t
   on t.StaffID = s.StaffID
group by s.Name
Random Solutions  
 
programming4us programming4us