当前位置: 移动技术网 > IT编程>数据库>MSSQL > 世界杯猜想活动的各类榜单的SQL语句小结

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

男孩车祸心脏破裂,暴雨天碰到这个要赶紧逃命!,珀尚

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

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网