题解 | #计算用户8月每天的练题数量#
计算用户8月每天的练题数量
http://www.nowcoder.com/practice/847373e2fe8d47b4a2c294bdb5bda8b6
以下仅为个人笔记
一开始陷入了一个误区,以为是把八月份的练题数量找出来,但是忽略了“每天”,利用时间函数,获取到8月份练题的天数,然后进行统计,再根据天进行分组
select day(date) day,count(question_id)
from
question_practice_detail question_cnt
where date like "%2021-08%"
group by day
时间函数:day year month
select day(date) day,
count(question_id) question_cnt
from question_practice_detail
where year(date)="2021" and
month(date)="08"
group by day
count(question_id) questiont_cnt
from
question_practice_detail
group by day