关键字 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;

tp只能写sql
laravel 当中做法

网友评论