SQL排序打分
发布网友
发布时间:2022-04-26 04:21
我来回答
共2个回答
热心网友
时间:2022-06-20 18:16
你要的是这种效果?
==>
select spropscore=1-(select count(*) from match where sprop>=a.sprop)*0.2+0.2
,* from match a order by sprop desc
参考资料:http://zhidao.baidu.com/question/74647893.html?fr=ala0
热心网友
时间:2022-06-20 18:17
SELECT id, name, sprop,
CASE WHEN spropscore > 0 THEN spropscore ELSE 0 END AS spropscore
FROM (SELECT id, name, sprop, 1 -
(SELECT COUNT(*) AS Expr1
FROM match
WHERE (sprop > a.sprop)) * 0.2 AS spropscore
FROM match AS a
ORDER BY sprop DESC) AS b