以下仅为个人笔记

一开始陷入了一个误区,以为是把八月份的练题数量找出来,但是忽略了“每天”,利用时间函数,获取到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

时间函数:date_format(date,"%Y-%m")

select DATE_FORMAT(date,"%d") day,

count(question_id) questiont_cnt

from

question_practice_detail

where date_format(date,"%Y-%m")="2021-08"

group by day