22,298
社区成员
发帖
与我相关
我的任务
分享
SELECT DrawID, KindID, ServerID, TableID, UserCount, AndroidCount, Waste, Revenue, UserMedal, StartTime, ConcludeTime, InsertTime, KindName, ServerName,
sum(Score) AS Score, max(BackScore) AS BackScore, BackInsureScore, gameid, accounts, nickname, lastlogonip, LastLogonType, userID
FROM (SELECT A.DrawID, A.KindID, A.ServerID, A.TableID, A.UserCount, A.AndroidCount, A.Waste, A.Revenue, A.UserMedal, A.StartTime, A.ConcludeTime,
A.InsertTime, B.KindName, C.ServerName, sum(D .Score) AS Score, CASE A.KindID WHEN 108 THEN max(d .BackScore - Score)
ELSE d .BackScore END AS BackScore, D .BackInsureScore, E.gameid, E.accounts, E.nickname, E.lastlogonip, E.LastLogonType, E.userID
FROM RecordDrawInfo AS A LEFT JOIN
GameKindItem AS B ON A.KindID = B.KindID LEFT JOIN
GameRoomInfo AS C ON A.ServerID = C.ServerID JOIN
RecordDrawScore AS D ON A.DrawID = D .DrawID LEFT JOIN
AccountsInfo AS E ON D .UserID = E.userID
GROUP BY A.DrawID, A.KindID, A.ServerID, A.TableID, A.UserCount, A.AndroidCount, A.Waste, A.Revenue, A.UserMedal, A.StartTime, A.ConcludeTime,
A.InsertTime, B.KindName, C.ServerName, D .Score, D .BackInsureScore, E.gameid, d .backinsurescore, e.accounts, E.nickname, E.lastlogonip,
E.LastLogonType, E.userID, d .BackScore) AS tab
GROUP BY DrawID, KindID, ServerID, TableID, UserCount, AndroidCount, Waste, Revenue, UserMedal, StartTime, ConcludeTime, InsertTime, KindName, ServerName,
BackInsureScore, gameid, accounts, nickname, lastlogonip, LastLogonType, userID
HAVING sum(Score) != 0
--先查看一下表页面碎片程度
dbcc showcontig(RecordDrawInfo)
dbcc showcontig(RecordDrawScore)