题解 | #计算用户8月每天的练题数量#
计算用户8月每天的练题数量
http://www.nowcoder.com/practice/847373e2fe8d47b4a2c294bdb5bda8b6
本题主要是时间的判断,以及如何把时间格式为日,可以参考我下面两种写法:
SELECT DATE_FORMAT(date,'%d') day,COUNT(question_id) question_cnt
FROM question_practice_detail
WHERE date >= '2021-08-01' AND date <= '2021-08-31'
GROUP BY date;
SELECT DATE_FORMAT(date,'%d') day,COUNT(question_id) question_cnt
FROM question_practice_detail
WHERE DATE_FORMAT(date,'%Y%m') = 202108
GROUP BY date;