Get count of one day, seven days and thirty days in MySQL -
i'm wondering if it's possible query like:
select count(distinct `user`) `test_table` `createddate` >= now() - interval 1 day day && select count(distinct `user`) `test_table` `createddate` >= now() - interval 7 day week && select count(distinct `user`) `test_table` `createddate` >= now() - interval 30 day month
the query ideally return amount of users created in past month/week/day.
select ifnull(sum(case when `createddate` >= curdate() - interval 1 day 1 else 0 end),'0') 'lastday', ifnull(sum(case when `createddate` >= curdate() - interval 7 day 1 else 0 end),'0') 'lastsevendays', ifnull(sum(case when `createddate` >= curdate() - interval 30 day 1 else 0 end),'0') 'lastthirtydays' test_table `createddate` >= curdate() - interval 30 day;
Comments
Post a Comment