牛客网刷题学习SQL(八)

SQL28 计算用户8月每天的练题数量

在这里插入图片描述
在这里插入图片描述
问题分解:
限定条件:2021年8月,写法有很多种,比如用year/month函数的year(date)=2021 and month(date)=8,比如用date_format函数的date_format(date, “%Y-%m”)=“202108”
每天:按天分组group by date
题目数量:count(question_id)

select day(date) day , count(question_id) question_id
from question_practice_detail qpd
where date_format(date,'%Y-%m')='2021-08'
group by day

select day(date) day , count(question_id) question_id
from question_practice_detail qpd
where year(date)=2021 and month(date)=8
group by day

猜你喜欢

转载自blog.csdn.net/qq_53037676/article/details/131014589