Sum up values..
- I am still pretty green at this SQL stuff, so I will try to explain
this as best as I can.
I have a table of stats, for a bunch of teams. I need to be able to
Sum up the teams points, wins, losses and ties for the season.
I have a table structure that looks like this:
DI.AutoDivisionID -> DITMap.DivisionInfoID AND DITMap.TeamInfoID ->
TI.AutoTeamID AND TI.AutoTeamID -> TSMap.TeamInfoID AND
TSMap.TeamStatsID -> TS.AutoTeamStatsID..
I hope this makes sense..?
I have the following SELECT:
SELECT * FROM DivisionInfo AS DI, DivisionInfoTeamMap AS DITMap,
TeamInfo AS TI, TeamStatsMap AS TSPMap, TeamStats AS TS WHERE
DI.AutoDivisionID=30 And DI.AutoDivisionID=DITMap.DivisionInfoID And
With this, I get all the records for all the teams in the selected
division. (DI.AutoDivisionID=30) So if I have 3 weeks of stats in the
table, I get all the records, for all the teams, for all 3 weeks.
What I want to be able to do, is Sum up all the points, wins, losses
and ties for each of the teams, for the 3 weeks and ORDER BY Points
DESC.. I am sure I am going to need to use SELECT Sum(Points)...
FROM ... WHERE ... IN ( SELECT .... FROM ... WHERE .....) but I am
not really sure how to do this..?
Thanks in advance...!
- Hi Scott.
Sorry I don't have a lot of time to understand you names and Database structure in depth.
If no-one else helps please post the following and I will gladly have a look at it.
Post a small sample of some data (simplified) and then also what you want to get out.
Create Table #TempPOC( ID int , value varchar(20))
Insert into #TempPOC ( 1 , "Anton" )
Insert into #TempPOC ( 1 , "AntonB" )
Insert into #TempPOC ( 1 , "AntonC" )
Drop Table #TempPOC
How do I extract only the 1st instance of "Anton"
This will allow me to much quicker understand what you want, and give me a base to work from (as I just past it into QA (assuming its MS based) )
Maybe wait another day or so, and then do it. There might be someone in another time zone that will answer it shortly.
From: Scott Barrett [mailto:scottsbmw@...]
Sent: 06 August 2004 07:06
Subject: [SQLQueriesNoCode] Sum up values..
The contents of this e-mail and any accompanying documentation
are confidential and any use thereof, in what ever form, by anyone
other than the addressee is strictly prohibited.