|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Complex Running Total (Sum)
Hello, and I hope someone can help me. I have a rather problematic SQL problem. So, let me lay out my data first (Table name is Pitchers):
GameID| Pitcher| Hits 1| Smith| 4 1| Jones| 3 2| Williams| 6 2| Johnson| 3 Now, the results I want: GameID| Hits| HitstoDate 1| 7 | 7 2| 9 | 16 The SQL Statement I tried: SELECT Pitchers.GameID, Sum(Pitchers.Hits) AS Hits, (Select Sum(Pitchers.Hits) from Pitchers as Temp Where Temp.GameID <= GameLog.GameID) as RunningTotal FROM GameLog INNER JOIN Pitchers ON GameLog.GameID = Pitchers.GameID GROUP BY Pitchers.GameID; (GameLog is the main table that contains other game information. Each game is listed in there only once. The Pitchers table contains information on each pitchers performance in that game.) The error I get with this is: "You tried to execute a query that does not include the specified expression 'GameID' as part of an aggregate function." Can any one offer any suggestions? Thanks, OT P.S. I am using Access. |
|
#2
|
|||
|
|||
|
RE: Complex Running Total (Sum)
Nevermind...I figured it out. Just a stupid omission that's too embarrassing to point out.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Complex Running Total (Sum) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|