首页 > 代码库 > 【MySQl】按所有,今日,本月,24小时每一小时统计
【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小时每一小时统计
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。