MySQl按所有,今日,本月,24小时每一小时统计
Posted 丶会飞的羊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQl按所有,今日,本月,24小时每一小时统计相关的知识,希望对你有一定的参考价值。
-- 24小时
SELECT HOUR (create_date) AS hours, SUM(source_amount) sm_source_amount, SUM(ticket_count*purchase_price) AS sm_purchase_amount FROM ticket_order WHERE DATE_FORMAT(create_date, ‘%Y-%m-%d‘) = ‘2017-05-12‘ AND scenic_id in(1,2,3); GROUP BY HOUR (create_date); select hour(create_date) as hours,ticket_count,create_date from ticket_order where DATE_FORMAT(create_date,‘%Y-%m-%d‘) = ‘2017-05-12‘ group by hour(create_date); -- 天 SELECT SUM(source_amount) AS sm_source_amount, SUM(ticket_count) AS sm_ticket_count FROM ticket_order WHERE DATE_FORMAT(create_date, ‘%Y-%m-%d‘) = ‘2017-05-17‘; -- 月 SELECT SUM(source_amount) AS sm_source_amount, SUM(ticket_count) AS sm_ticket_count FROM ticket_order WHERE DATE_FORMAT(create_date, ‘%Y-%m‘) = ‘2017-05‘; -- 所有 SELECT SUM(source_amount) AS sm_source_amount, SUM(ticket_count) AS sm_ticket_count FROM ticket_order;
以上是关于MySQl按所有,今日,本月,24小时每一小时统计的主要内容,如果未能解决你的问题,请参考以下文章
MySQL分页时统计总记录行数并使用limit返回固定数目的记录
错误:EPERM:不允许操作,错误时统计“D:\System Volume Information”(本机)
Tensorboard - 分析计算时间 - 运行时统计中的一切都是“未使用的子结构”