题解 | #计算用户8月每天的练题数量#
计算用户8月每天的练题数量
http://www.nowcoder.com/practice/847373e2fe8d47b4a2c294bdb5bda8b6
要求
计算用户8月每天的练题数量
思路
- 8月:EXTRACT(Month from date) = 08
- 每天: Distinct EXTRACT(DAY from date)
- 练题数量:count(result)
实现
SELECT DISTINCT EXTRACT(DAY from date) AS day, COUNT(result) as question_cnt
FROM question_practice_detail
WHERE EXTRACT(MONTH from date) = 08
GROUP BY day