原始数据是 每人,每分钟,每个房间的观看数目标查出 每人每天的的最大数(计算所有房间每分钟的数,然后取最大的那分钟的数据当每日的峰值)。人 id 分钟timer 观看数num 房间 room_id有大神帮忙一起想想sql怎么写?
1 回答
手掌心
TA贡献1942条经验 获得超3个赞
SELECT max(t1.sumNum) as maxNum, r.timer_count as tsMax, r.admin_id as admin_idfrom( select t.* from ( select admin_id,timer_count,sum(num) As sumNum from room_running where timer_type = 'minute' and timer_count between 25532160 and 25533599 and ref_host = "" and room_id > 0 group by admin_id,timer_count )t ORDER BY t.sumNum DESC,t.timer_count desc)t1JOIN room_running r ON r.timer_count = t1.timer_count AND r.admin_id = t1.admin_id AND r.num = t1.sumNum GROUP BY admin_id ORDER BY maxNum DESC
- 1 回答
- 0 关注
- 2530 浏览
添加回答
举报
0/150
提交
取消