当前位置:Gxlcms > mysql > mysql常用_MySQL

mysql常用_MySQL

时间:2021-07-01 10:21:17 帮助过:37人阅读

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 是为了去除因比较值重复的情况发生

人气教程排行