对于日期数据2021-05-03
,有日期函数year()
、month()
和day()
,它们三个函数分别取出日期数据中的年、月和日。
例如,
select day(date) as day, count(id) from question_practice_detail
where year(date) = '2021' and month(date) = '08'
group by date;
也可以写成这种形式,
select day(date) as day, count(id) from question_practice_detail
where year(date) = 2021 and month(date) = 8
group by date;