世界杯猜想活動(dòng)的各類榜單的SQL語(yǔ)句小結(jié)
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
/*正確率錯(cuò)誤率排名*/
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
/*冷門場(chǎng)次排名*/
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
/*冷門場(chǎng)次的命中者*/
Select top 50 UserName,sum(ReceivePrice) as ReceivePrice
From [game_FantasyLog] where topicid=29
GROUP BY TopicId,UserName
ORDER BY sum(ReceivePrice) DESC
相關(guān)文章
SqlServer 在事務(wù)中獲得自增ID的實(shí)例代碼
這篇文章主要介紹了 SqlServer 在事務(wù)中獲得自增ID實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-03-03檢測(cè)SqlServer數(shù)據(jù)庫(kù)是否能連接的小技巧
這篇文章主要介紹了檢測(cè)SqlServer數(shù)據(jù)庫(kù)是否能連接的小技巧,本文使用UDL文件的形式實(shí)現(xiàn)這個(gè)小方法,需要的朋友可以參考下2015-02-02安裝SQL2008時(shí)提示刪除SQL2005Express工具的解決方法
在安裝SQL2008的時(shí)候,提示要?jiǎng)h除SQL2005EXPRESS工具,在網(wǎng)上找了很多資料,終于找到一個(gè)比較方便的方法了,希望能幫助大家。2010-07-07簡(jiǎn)析SQL Server數(shù)據(jù)庫(kù)用視圖來(lái)處理復(fù)雜的數(shù)據(jù)查詢關(guān)系
本文我們主要介紹了SQL Server數(shù)據(jù)庫(kù)用視圖來(lái)處理復(fù)雜的數(shù)據(jù)查詢關(guān)系的相關(guān)知識(shí),以及視圖的優(yōu)缺點(diǎn)和創(chuàng)建方式以及注意事項(xiàng)的相關(guān)知識(shí),需要的朋友可以參考下2015-08-08sqlserver循環(huán)刪除表中的數(shù)據(jù)最好方案
這篇文章主要介紹了sqlserver?中?循環(huán)刪除表中的數(shù)據(jù),這樣不會(huì)鎖表,導(dǎo)致業(yè)務(wù)出現(xiàn)問(wèn)題,本文給大家分享最新解決方案,文中給大家補(bǔ)充介紹了foreach 循環(huán)中刪除一條數(shù)據(jù)_SQL Server中刪除重復(fù)數(shù)據(jù)的幾個(gè)方法,需要的朋友可以參考下2023-11-11有關(guān)sqlserver帳號(hào)被禁用的處理方法
這篇文章主要介紹了有關(guān)sqlserver帳號(hào)被禁用處理方法,需要的朋友可以參考下2017-12-12推薦SQL Server 重新恢復(fù)自動(dòng)編號(hào)列的序號(hào)的sql代碼
推薦SQL Server 重新恢復(fù)自動(dòng)編號(hào)列的序號(hào)的sql代碼...2007-08-08用SQL腳本讀取Excel中的sheet數(shù)量及名稱的方法代碼
這篇文章介紹了用SQL腳本讀取Excel中的sheet數(shù)量及名稱的方法代碼,有需要的朋友可以參考一下2013-09-09