我试图在单一询问中履行两个不同的特别论坛。
user points date_achieved
-----------------------------
Foo 10 2000-01-01
Foo 20 2011-11-18
Bar 10 2000-01-01
Bar 20 2011-11-15
Bar 30 2011-11-18
(1) 总数
SELECT user, SUM(points) AS points_total
FROM myTable
GROUP BY user
(2) 上个月累积的要点
SELECT user, SUM(points) AS points_month
FROM myTable
WHERE date_achieved >= CURRENT_DATE - INTERVAL 1 MONTH
GROUP BY user
如何以单一方式实现这一目标?
Many thanks.