加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 09:31:21 所属栏目:MsSql教程 来源:网络整理
导读:/ 增幅降幅排名 / div class="codetitle" a style="CURSOR: pointer" data="30488" class="copybut" id="copybut30488" onclick="doCopy('code30488')" 代码如下:div class="codebody" id="code30488" Select top 50 UserName,sum(ReceivePrice) - sum(Guess

/增幅降幅排名/
<div class="codetitle"><a style="CURSOR: pointer" data="30488" class="copybut" id="copybut30488" onclick="doCopy('code30488')"> 代码如下:<div class="codebody" id="code30488">
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

/
正确率错误率排名/
<div class="codetitle"><a style="CURSOR: pointer" data="22202" class="copybut" id="copybut22202" onclick="doCopy('code22202')"> 代码如下:<div class="codebody" id="code22202">
Select top 50 UserName,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

/大手笔排名/
<div class="codetitle"><a style="CURSOR: pointer" data="175" class="copybut" id="copybut175" onclick="doCopy('code175')"> 代码如下:<div class="codebody" id="code175">
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

/冷门场次排名/
<div class="codetitle"><a style="CURSOR: pointer" data="39696" class="copybut" id="copybut39696" onclick="doCopy('code39696')"> 代码如下:<div class="codebody" id="code39696">
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

/冷门场次的命中者/
<div class="codetitle"><a style="CURSOR: pointer" data="21134" class="copybut" id="copybut21134" onclick="doCopy('code21134')"> 代码如下:<div class="codebody" id="code21134">
Select top 50 UserName,sum(ReceivePrice) as ReceivePrice
From [game_FantasyLog] where topicid=29
GROUP BY TopicId,UserName
ORDER BY sum(ReceivePrice) DESC

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读