mysql根据时间统计数据语句

Posted 一生不过烟花

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql根据时间统计数据语句相关的知识,希望对你有一定的参考价值。

select FROM_UNIXTIME(`createtime`, ‘%Y年%m月%d日‘)as retm,count(*) as num  from `user` GROUP BY retm

select FROM_UNIXTIME(`pay_tm`, ‘%Y/%m/%d::‘)as retm,sum(price)+sum(express_price) as num from `order_orderlist` GROUP BY retm;

select FROM_UNIXTIME(`pay_tm`, ‘%Y/%m/%d::‘)as retm,SUM(a2.`num`)  AS num from `order_orderlist` as a1 INNER JOIN `order_orderlistrow` as a2 on a1.`id` = a2.`order_orderlist_id`  GROUP BY retm;

select FROM_UNIXTIME(`pay_tm`, ‘%Y/%m/%d::‘)as retm,count(*) as num from `order_orderlist` GROUP BY retm;

 

以上是关于mysql根据时间统计数据语句的主要内容,如果未能解决你的问题,请参考以下文章

MySQL关于根据日期查询数据的sql语句

MySQL根据某一个或者多个字段查找重复数据的sql语句

MySQL explain根据查询计划去优化SQL语句

mysql-回复DELETE数据

mysql-----sql语句

mysql 根据时间段删除