这是原始数据 想按照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;
得到结果