查询第一次充值100的玩家 后面一共充值多少的订单
作者:互联网
select uid,SUM(amount) as num from pay_record where uid in(select uid from (SELECT * FROM `pay_record` GROUP BY uid) as a where amount =100) GROUP BY uid HAVING num >=10001 and num<=20000 ORDER BY num desc
SELECT * FROM `pay_record` GROUP BY uid 分组去重后得到的是每个uid升序的第一条订单(要去分组后降序的第一条订单 要先把原始数据降序排序后再分组) 然后判断条件 得到符合条件的uid 然后再统计数据
标签:GROUP,uid,record,pay,玩家,充值,num,分组,100 来源: https://blog.csdn.net/liuxin_0725/article/details/123628990