mysql按字段分组并获取每个分组按照某个字段排序的前三条
时间:2021-07-01 10:21:17
帮助过:3人阅读
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;
得到结果
mysql按字段分组并获取每个分组按照某个字段排序的前三条
标签: