mysql 取分数排名 0.5-0.8 数据
SELECT * FROM ( SELECT * FROM ( SELECT @rownum := @rownum + 1 rownum, ## 获取行号 u2.* FROM ( SELECT @rownum := 0 ) t1, ( SELECT * FROM yide_user2 u ORDER BY u.total_scores + 0 DESC ) u2 ) a ) a WHERE ( ## 取行号后0.5 a.rownum > ( SELECT round( count( * ) / 2 ) FROM yide_user2 ) ## 取行号前0.8 AND a.rownum < ( SELECT round( count( * )*0.8 ) FROM yide_user2 ) ) LIMIT 0, 20
mysql 取分数排名 前0.2数据
( SELECT @rownum := @rownum + 1, u2.* FROM ( SELECT @rownum := 0 ) t1, ( SELECT * FROM yide_user2 u ORDER BY u.total_scores + 0 DESC ) u2 WHERE @rownum < ( SELECT round( count( * ) / 5 ) FROM yide_user2 ) )