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 |
iancuct
Yak Posting Veteran
73 Posts |
Posted - 2002-09-30 : 11:31:30
|
Hi I have a table that i want to do a running totals on one of the colums , the table is actually a querry , so i am doing a select withing a select but access does not let me save the query something about syntax here is my querry SELECT A.WeekEndingDate, A.SumOfBudgetedSpent, SUM(B.SumOfBudgetedSpent) FROM ( ( SELECT EVMS_SubTaskSpending.WeekEndingDate, Sum(EVMS_SubTaskSpending.BudgetedSpent) AS SumOfBudgetedSpent FROM EVMS_SubTaskSpending WHERE (((EVMS_SubTaskSpending.ChargeNumber)=[Forms]![EVMS-Select Task]![cmb_ChargeNumber]) AND ((EVMS_SubTaskSpending.JobNumber)=[Forms]![EVMS-Select Task]![cmb_Job])) GROUP BY EVMS_SubTaskSpending.WeekEndingDate ) AS A CROSS JOIN ( SELECT EVMS_SubTaskSpending.WeekEndingDate, Sum(EVMS_SubTaskSpending.BudgetedSpent) AS SumOfBudgetedSpent FROM EVMS_SubTaskSpending WHERE (((EVMS_SubTaskSpending.ChargeNumber)=[Forms]![EVMS-Select Task]![cmb_ChargeNumber]) AND ((EVMS_SubTaskSpending.JobNumber)=[Forms]![EVMS-Select Task]![cmb_Job])) GROUP BY EVMS_SubTaskSpending.WeekEndingDate ) AS B ) Where (B.WeekEndingDate<=A.WeekEndingDate) As RunningTotal GROUP BY A.WeekEndingDate, A.SumOfBudgetedSpent ORDER BY A.WeekEndingDate, A.SumOfBudgetedSpent This is the table that the subquery returns so WeekEndingDate SumOfBudgetedSpent 4/14/2002 $453.37 4/21/2002 $453.37 4/28/2002 $453.37 5/5/2002 $453.37 5/12/2002 $453.37 5/19/2002 $453.37 i am tring to crossjoing the subqueries and get a variation of the above table with an additional column with the Cummulative SumOfBudgetedSpent so it would look something like this WeekEndingDate SumOfBudgetedSpent 4/14/2002 $453.37 4/21/2002 $906.74 4/28/2002 $1360.11 why isn't access acepting my query please help |
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-09-30 : 13:38:45
|
AFAIK Access does not support the CROSS JOIN syntax. Replace that with a , |
 |
|
iancuct
Yak Posting Veteran
73 Posts |
Posted - 2002-10-01 : 11:00:49
|
i did replace the syntax so that it looks like the following querySELECT A.WeekEndingDate, A.SumOfBudgetedSpent, SUM(B.SumOfBudgetedSpent)FROM( SELECT EVMS_SubTaskSpending.WeekEndingDate, Sum(EVMS_SubTaskSpending.BudgetedSpent) AS SumOfBudgetedSpentFROM EVMS_SubTaskSpendingWHERE (((EVMS_SubTaskSpending.ChargeNumber)=[Forms]![EVMS-Select Task]![cmb_ChargeNumber]) AND ((EVMS_SubTaskSpending.JobNumber)=[Forms]![EVMS-Select Task]![cmb_Job]))GROUP BY EVMS_SubTaskSpending.WeekEndingDate) A,(SELECT EVMS_SubTaskSpending.WeekEndingDate, Sum(EVMS_SubTaskSpending.BudgetedSpent) AS SumOfBudgetedSpentFROM EVMS_SubTaskSpendingWHERE (((EVMS_SubTaskSpending.ChargeNumber)=[Forms]![EVMS-Select Task]![cmb_ChargeNumber]) AND ((EVMS_SubTaskSpending.JobNumber)=[Forms]![EVMS-Select Task]![cmb_Job]))GROUP BY EVMS_SubTaskSpending.WeekEndingDate) BWhere (B.WeekEndingDate <= A.WeekEndingDate) As RunningTotalGROUP BY A.WeekEndingDate, A.SumOfBudgetedSpentORDER BY A.WeekEndingDate, A.SumOfBudgetedSpentand now it gives me a different error messegeSyntax Error (missing operator) in query expression '(B.WeekEndingDate <= A.WeekEndingDate) As RunningTotal"Can anyone help please |
 |
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-10-01 : 11:57:27
|
Here is one further problemWhere (B.WeekEndingDate <= A.WeekEndingDate) As RunningTotal You can not specify correlation names in the where clause, so remove As RunningTotal |
 |
|
|
|
|
|
|