date_sub的用法

date_sub('2019-07-27', interval 30 day)表示往前推30天或者往后推30天

 

select activity_date day, count(distinct user_id) active_users
from activity
where activity_date > date_sub('2019-07-27', interval 30 day)
and activity_date <= '2019-07-27'
group by activity_date

©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页