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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 need help with crayze join...

Author  Topic 

simakas
Starting Member

3 Posts

Posted - 2005-04-08 : 06:17:18
hi folks,

Title: agenda
need help with the query that is almost finished

Title: situation
tables: player, game(i.e. tenis), playerPointsOfCurrentGame

Title: expectations
i expect a result querie of: players, their top 7 game points by date, the sum of top 7 game points

Title: what i have
with 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 t
inner
join zaidimas as gpp
on t.game_no = gpp.turnyras
right
join zaidejas as p
on gpp.zaidejas = p.id
group by pavarde, vardas, id
order by suma desc

Title: current problem
the querie sintax is ok, but i absolutely dont get, what is done the first rows of this queriw
how 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 top7byDate

Title: help
help!!!

Title: thank you
thank you :)

________________
simakas

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-04-10 : 20:09:50
hi simakas

could 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"
Go to Top of Page
   

- Advertisement -