Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
simakas
Starting Member
3 Posts |
Posted - 2005-04-08 : 06:17:18
|
| hi folks,Title: agendaneed help with the query that is almost finishedTitle: situationtables: player, game(i.e. tenis), playerPointsOfCurrentGameTitle: expectationsi expect a result querie of: players, their top 7 game points by date, the sum of top 7 game pointsTitle: what i havewith the help of ppl in forums i build a crayze querie:select top 7 identity(smallint,1,1) as game_no into top7games from zaidimas select p.id, p.vardas, p.pavarde , sum(case when t.game_no=1 then gpp.taskai else 0 end) as [points top] , sum(case when t.game_no=2 then gpp.taskai else 0 end) as [points top-1] , sum(case when t.game_no=3 then gpp.taskai else 0 end) as [points top-2] , sum(case when t.game_no=4 then gpp.taskai else 0 end) as [points top-3] , sum(case when t.game_no=5 then gpp.taskai else 0 end) as [points top-4] , sum(case when t.game_no=6 then gpp.taskai else 0 end) as [points top-5] , sum(case when t.game_no=7 then gpp.taskai else 0 end) as [points top-6] ,sum(gpp.taskai) as suma from top7games as tinner join zaidimas as gpp on t.game_no = gpp.turnyrasright join zaidejas as p on gpp.zaidejas = p.id group by pavarde, vardas, idorder by suma descTitle: current problemthe querie sintax is ok, but i absolutely dont get, what is done the first rows of this queriwhow to get a temp table or resultSet of top 7 games (by date) and to find player points in current games... ...this querie rezults player names with 7 game points, but the games arent top7byDateTitle: helphelp!!!Title: thank youthank you :)________________simakas |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2005-04-10 : 20:09:50
|
hi simakascould you post some example data eg:create table Games(player nvarchar(100), game nvarchar(100), playerPointsOfCurrentGame Integer)insert into Games(player, game, playerPointsOfCurrentGame) values( rob , tennis , 3)insert into Games(player, game, playerPointsOfCurrentGame) values( simakas , tennis , 4) --I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
|
|
|
|
|