首页 > 资讯列表 > 编程/数据库 >> 数据库操作教程

世界杯猜想活动的各类榜单的SQL语句小结

数据库操作教程 2022-09-23 20:22:39 转载来源: 网络整理/侵权必删

/*增幅降幅排名*/复制代码代码如下:Selecttop50UserName,sum(ReceivePrice)-sum(GuessPrice)asReceivePrice,cast(sum(CASEWHENReceivePrice>0THEN1.0ELSE0END)/count(ReceivePrice)*100asnumeric(4,1))asRateFrom[game_FantasyLog]WHEREIsJudge=1GROUPBYUserId,UserNameORDERBYsum(ReceivePrice)-sum(GuessPrice)ASC/*正确率错误率排名*/复制代码代码如下:Selecttop50UserName,sum(ReceivePrice)-sum(GuessPrice)asReceivePrice,cast(sum(CASEWHENReceivePrice>0THEN1

/*增幅降幅排名*/
复制代码 代码如下:

Select top 50 UserName,sum(ReceivePrice) - sum(GuessPrice) as ReceivePrice,
cast(sum(CASE WHEN ReceivePrice>0 THEN 1.0 ELSE 0 END) / count(ReceivePrice) * 100 as numeric(4,1)) as Rate
From [game_FantasyLog]
WHERE IsJudge=1
GROUP BY UserId,UserName
ORDER BY sum(ReceivePrice) - sum(GuessPrice) ASC

/*正确率错误率排名*/
复制代码 代码如下:

Select top 50 UserName,sum(ReceivePrice) - sum(GuessPrice) as ReceivePrice,
cast(sum(CASE WHEN ReceivePrice>0 THEN 1.0 ELSE 0 END) / count(ReceivePrice) * 100 as numeric(4,1)) as Rate
From [game_FantasyLog]
WHERE IsJudge=1
GROUP BY UserId,UserName Having count(UserId) >= 5
ORDER BY cast(sum(CASE WHEN ReceivePrice>0 THEN 1.0 ELSE 0 END) / count(ReceivePrice) * 100 as numeric(4,1)) ASC

/*大手笔排名*/
复制代码 代码如下:

Select top 50 l.UserName,sum(l.GuessPrice),sum(l.ReceivePrice),f.title
From [game_FantasyLog] l left join [game_fantasy] f on l.topicid = f.id
GROUP BY l.TopicId,l.UserName,f.title
ORDER BY sum(l.GuessPrice) DESC

/*冷门场次排名*/
复制代码 代码如下:

Select top 50 f.id,f.title,f.GuessPrice,(select sum(receivePrice) FROM [game_FantasyLog] l where l.topicid = f.id),
cast((select sum(CASE WHEN ReceivePrice>0 THEN 1.0 ELSE 0 END) / f.GuessTimes FROM [game_FantasyLog] l2 where l2.topicid = f.id) as numeric(4,2))
From [game_Fantasy] f WHERE f.GuessPrice > 1000
ORDER BY (select sum(receivePrice) FROM [game_FantasyLog] l where l.topicid = f.id) ASC

/*冷门场次的命中者*/
复制代码 代码如下:

Select top 50 UserName,sum(ReceivePrice) as ReceivePrice
From [game_FantasyLog] where topicid=29
GROUP BY TopicId,UserName
ORDER BY sum(ReceivePrice) DESC

标签: 世界杯 猜想 活动 各类 榜单 SQL 语句 小结


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持