服务器之家

服务器之家 > 正文

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

时间:2019-11-28 15:08     来源/作者:MSSQL教程网

/*增幅降幅排名*/ 

复制代码代码如下:


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 

标签:

相关文章

热门资讯

玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
配置IIS网站web服务器的安全策略配置解决方案
配置IIS网站web服务器的安全策略配置解决方案 2019-05-23
Nginx服务器究竟是怎么执行PHP项目
Nginx服务器究竟是怎么执行PHP项目 2019-05-24
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情 2019-06-22
返回顶部