SQL SERVER世界杯猜想活动的各类榜单的SQL语句小结
2022-11-12 09:54:07
内容摘要
这篇文章主要为大家详细介绍了SQL SERVER世界杯猜想活动的各类榜单的SQL语句小结,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!/*增幅降
文章正文
这篇文章主要为大家详细介绍了SQL SERVER世界杯猜想活动的各类榜单的SQL语句小结,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
/*增幅降幅排名*/代码如下:
1 2 3 4 5 6 7 8 | <code> 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 </code> |
代码如下:
1 2 3 4 5 6 7 8 | <code> 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 </code> |
代码如下:
1 2 3 4 5 6 | <code> 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 </code> |
代码如下:
1 2 3 4 5 6 | <code> 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 </code> |
代码如下:
1 2 3 4 5 6 | <code> Select top 50 UserName,sum(ReceivePrice) as ReceivePrice From [game_FantasyLog] where topicid=29 GROUP BY TopicId,UserName ORDER BY sum(ReceivePrice) DESC </code> |
注:关于SQL SERVER世界杯猜想活动的各类榜单的SQL语句小结的内容就先介绍到这里,更多相关文章的可以留意
代码注释