Hi,
I am trying to join two tables - One called Users (contains UserID, FirstName, Surname) with another called CPD and I want to get a total of CPDPoints for each user.
So far this works fine:
SELECT Users.UserID, FirstName, Surname, SUM(CPDPoints) AS LowestYearTotal
FROM Users LEFT JOIN CPD ON Users.UserID=CPD.UserID
GROUP BY Users.UserID, Users.FirstName, Users.Surname;
However I want it to only add up CPDPoints for each person where CPD.CPDDate=2004 and store this in LowestYearTotal. In the same recordset I want to have SUM(CPDPoints) AS MiddleYearTotal WHERE CPD.CPDDate=2005.
Am not sure how to go about doing this - any help much appreciated!
Thanks
Ed
I am trying to join two tables - One called Users (contains UserID, FirstName, Surname) with another called CPD and I want to get a total of CPDPoints for each user.
So far this works fine:
SELECT Users.UserID, FirstName, Surname, SUM(CPDPoints) AS LowestYearTotal
FROM Users LEFT JOIN CPD ON Users.UserID=CPD.UserID
GROUP BY Users.UserID, Users.FirstName, Users.Surname;
However I want it to only add up CPDPoints for each person where CPD.CPDDate=2004 and store this in LowestYearTotal. In the same recordset I want to have SUM(CPDPoints) AS MiddleYearTotal WHERE CPD.CPDDate=2005.
Am not sure how to go about doing this - any help much appreciated!
Thanks
Ed