mysql 按百分比 比例查询数据
作者:互联网
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 )
)
标签:0.8,百分比,user2,yide,查询,mysql,rownum,u2,SELECT 来源: https://blog.csdn.net/twscsdn/article/details/120082732