这是原始数据 想按照brand_id分组 并获取每个分组total_num最高的前3位
SQL语句为:
select a.* from data a where 3 > (select count(*) from data where brand_id = a.brand_id and total_num > a.total_num ) order by a.brand_id, a.total_num desc;
得到结果
这是原始数据 想按照brand_id分组 并获取每个分组total_num最高的前3位
SQL语句为:
select a.* from data a where 3 > (select count(*) from data where brand_id = a.brand_id and total_num > a.total_num ) order by a.brand_id, a.total_num desc;
得到结果
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。