美文网首页
分组统计,再统计分组

分组统计,再统计分组

作者: dongdog | 来源:发表于2020-06-08 11:25 被阅读0次

关键字 WITH ROLLUP 回溯统计
替换空 coalesce(hour, '总计')

小时总计,天总计,总计


SELECT
       coalesce(date, '总计')      as date,
       coalesce(hour, '日计')         as 'hour',
       coalesce(game_id, '小时计')      as game_id2,
       sum(spin_count)              as spin_count,
       sum(spin_cost)               as spin_cost,
       sum(spin_get)                as spin_get,
       sum(free_spin_get)           as free_spin_get,
       sum(tiny_game_get)           as tiny_game_get,
       sum(free_spin_tiny_game_get) as free_spin_tiny_game_get
FROM newCenter.tbl_game_log
WHERE `date` BETWEEN '2020-06-05' AND '2020-06-05' 

GROUP BY `date`,`hour`, game_id WITH ROLLUP;

image.png

tp只能写sql
laravel 当中做法


image.png

相关文章

网友评论

      本文标题:分组统计,再统计分组

      本文链接:https://www.haomeiwen.com/subject/wtixtktx.html