Mysql日期函数的使用

  • 方式一
select
  dayofmonth(date) day,
  count(*) question_cnt
from
  question_practice_detail
where
  date like '2021-08%'
group by
  date
  • 方式二
select
    day(date) as day,
    count(question_id) as question_cnt
from question_practice_detail
where month(date)=8 and year(date)=2021
group by date