表结构如下:
CREATE TABLE [JNgameUserPoint] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[GameID] [int] NULL ,
[userID] [int] NULL ,
[point] [int] NULL
) ON [PRIMARY]
GO
要求:找出每个游戏中的积分point是最大的那个用户,即第一名的用户。
select t3.gameid,t3.gamename,max(t3.point) from
(
select t1.point,t2.gameid,t2.gamename from JNgameUserPoint t1
left join gameinfo t2 on t1.gameid = t2.gameid
) t3
group by t3.gameid,t3.gamename order by t3.gameid
要求:找出每个游戏中的总积分.
select t3.gameid,t3.gamename,sum(t3.point) from
(
select t1.point,t2.gameid,t2.gamename from JNgameUserPoint t1
left join gameinfo t2 on t1.gameid = t2.gameid
) t3
group by t3.gameid,t3.gamename order by t3.gameid