SELECT category_id, SUM(payment_amount) AS Total FROM Payments GROUP BY category_id WHERE MONTH(payment_date) = 01 ORDER BY SUM(payment_amount) DESC LIMIT 1
SELECT category_id, SUM(payment_amount) AS Total FROM Payments WHERE MONTH(payment_date) = 1 GROUP BY category_id ORDER BY SUM(payment_amount) DESC LIMIT 1
1条答案
按热度按时间y53ybaqx1#
语句的group by部分需要位于where子句之后,因此您的查询应该是: