我正在尝试查询我的奖励数据库,以了解员工本周总共分配了多少积分。
我用来计算老师分配的总分的查询如下:
SELECT `Giver_ID` , SUM( `Points` ) AS TotalPoints
FROM `transactions`
GROUP BY `Giver_ID`
ORDER BY `Giver_ID` ASC
我用来计算每周分配的查询非常相似:
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
我的问题是:是否可以将查询组合起来生成Giver_ID
,TotalPoints
并WeeklyPoints
从单个查询?
提前致谢,