1
我需要獲取一週內註冊的用戶數,給定開始日期和結束日期。 現在所用的邏輯是:Mysql獲取兩個日期之間的每週報告
week_days_list = [['2017-01-01', '2017-01-07'], ['2017-01-08', '2017-01-14']]
for week in week_days_list:
query = 'SELECT COUNT('*') AS `__count` FROM `user_table`
INNER JOIN `user_auth` ON (`user_table`.`user_id` = `user_auth`.`id`)
WHERE `user_auth`.`date_joined` BETWEEN week[0]
AND week[1];'
結果是:
__count
我希望它也降低到1個查詢。 例如:
Week Interval | count
'2017-01-01'| 15
'2017-01-08'| 12