当前位置:  数据库>sqlserver

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

    来源: 互联网  发布时间:2014-10-04

    本文导语:  /*增幅降幅排名*/ 代码如下: 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 su...

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

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

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 知不知道新浪的图文直播世界杯是怎样实现自动刷新的?
  • 今天世界杯开幕,终于可以看球了,高兴,散分,也愿中国臭脚们取得好成绩!
  • 令人失望的世界杯,放分!!!!!!!!!
  • CCTV5解说世界杯的妞--1小时后揭贴


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3