当前位置: 首页 > 工具软件 > xy-server > 使用案例 >

统计每日单量MySQL语句,进行XY轴展示

顾承平
2023-12-01

当我们遇到sql查询结果集进行横纵坐标展示时要用到分组函数,例子如下:
– 每日单量
select DATE_FORMAT(createtime,‘%Y-%m-%d’) as days,count() count from ibt_shop_order group by days;
– 每周单量
select DATE_FORMAT(createtime,‘%Y-%u’) as weeks,count(
) count from ibt_shop_order group by weeks;
– 每月单量
select DATE_FORMAT(createtime,‘%Y-%m’) as months,count(*) count from ibt_shop_order group by months;

 类似资料: