mysql常用_MySQL
程序员文章站
2022-06-17 13:04:07
...
1、mysql 分组取前N记录
select present_price,userid from wx_goods a where 2 > (select count(*) from wx_goods where userid=a.userid and present_price>a.present_price) GROUP BY present_price ORDER BY userid,present_price desc
其中 GROUP BY present_price 是为了去除因比较值重复的情况发生