I’m trying to query my reward database to work out how many points members of staff have allocated in total and this week.
The query that I’m using to work out the total points a teacher has allocated is as follows:
SELECT `Giver_ID` , SUM( `Points` ) AS TotalPoints
FROM `transactions`
GROUP BY `Giver_ID`
ORDER BY `Giver_ID` ASC
The query that I’m using to work out weekly allocations is very similar:
SELECT `Giver_ID` , SUM( `Points` ) AS WeeklyPoints
FROM `transactions`
WHERE ( `Datetime` >= '2012-09-24' AND `Datetime` <= '2012-09-30' )
GROUP BY `Giver_ID`
ORDER BY `Giver_ID` ASC
My question is this: is it possible to combine the queries to produce Giver_ID, TotalPoints and WeeklyPoints from a single query?
Thanks in advance,
Yes, it is possible –