Hey all, i am trying to create a report to show how much is spent per HRCode. This is my SQL Query so far:
SELECT *
FROM tblWO as WO,
tblWOD as WOD,
tblWA as WA
WHERE WOD.OrderID = WO.ID
AND WA.HRCode = WO.AdministratorCode
AND WO.OrderDate BETWEEN '2010-01-01' AND '2010-08-31'
AND Approved = '1'
ORDER BY WO.OrderDate
I'm trying to fingure out a way that mash all the same HRCode's together and then SUM() each... But my brain is not working today so i need some help :o)
Here is what the database data looks like:
ID Total OrderDate Approved HRCode AdministratorCode OrderID
3272 25.00 2010-01-04 10:48:57.617 1 RN RN 3272
4621 25.00 2010-02-04 11:15:01.600 1 RN RN 4621
4899 50.00 2010-02-04 11:55:01.630 1 02 02 4899
4905 15.00 2010-05-04 11:55:01.190 1 NR NR 4905
5001 50.00 2010-06-04 04:11:55.295 1 RN RN 5001
Any help would be great! Thanks!
SOLVED
SELECT SUM(Total) as Total, AdministratorCode
FROM tblWO as WO,
tblWOD as WOD
WHERE WOD.OrderID = WO.ID
AND WO.OrderDate BETWEEN '2010-01-01' AND '2010-08-31'
AND Approved = '1'
ORDER BY WO.AdministratorCode
David