1.商鋪須要查看一天 24 小時,00 到 24 點的每種訂單類型的收益
2.商鋪須要查看 一週,後者一個月的以天爲單位的每種訂單類型的收益
select FROM_UNIXTIME(create_time,"%H") as hour,sum(amount),order_type FROM order WHERE create_time BETWEEN '起始時間戳' AND '結束時間戳' AND pay_status in (1,3,5) GROUP BY hour,order_type ;
select FROM_UNIXTIME(create_time,"%d-%H") as hour,sum(amount),order_type FROM order WHERE create_time BETWEEN '起始時間戳' AND '結束時間戳' AND pay_status in (1,3,5) GROUP BY hour,order_type ;
先轉換時間戳類型,而後根據時間戳類型分組,求和就完成了mysql
1.date_diff
2.date_create
3.date_formate
4.date_add
5.date_interval_create_from_date_string