This week: Yearweek (Date_format (create_time, '%y-%m-%d ')) = Yearweek (now ())
Last week: Yearweek (Date_format (create_time, '%y-%m-%d ')) = Yearweek (now ())-1
Last week: Yearweek (Date_format (create_time, '%y-%m-%d ')) = Yearweek (now ())-2
Note that the history week only needs to subtract the corresponding number after Yearweek (now ())
Next week: Yearweek (Date_format (create_time, '%y-%m-%d ')) = Yearweek (now ()) +1
Note: The next week is in the back +1
Select SUM (Total_money) as this week sells the total amount from Crm_order_record where Yearweek (Date_format (create_time, '%y-%m-%d ')) = Yearweek (Now ())
and refund_money=0;
This month: Date_format (create_time, '%y-%m ') =date_format (now (), '%y-%m ')
Last month: Date_format (create_time, '%y-%m ') =date_format (Date_sub (Curdate (), INTERVAL 1 month), '%y-%m ')
Last month: Date_format (create_time, '%y-%m ') =date_format (Date_sub (Curdate (), INTERVAL 2 month), '%y-%m ')
History Month: Subtract the corresponding number of months from the back
MySQL's presentation on this week and last week