Heim >Datenbank >MySQL-Tutorial >mysql常用_MySQL
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 是为了去除因比较值重复的情况发生