Subquery for running sum blues.

J

Jaazaniah

Ok, this has been a challenge I've been trying off and on for about a
month now to solve. The speed issues related to domain aggregate
functions sent me looking for better methods. Over the past month or
so, I've been trying to impliment the subquery method posted various
times to this and other groups. The reason for wanting query-level
running sum is so that a graph in the report can use the data. This is
the SQL for of what I've been trying:

SELECT [Month], (SELECT SUM([CUS]) FROM [OwnerByMonth] T2
WHERE T2.[Month] <= T1.[Month]) AS RunningSum
FROM [OwnerByMonth] T1
ORDER BY [Month]

[Month] is a calculated Date field (using CDate() to avoid Variant)
for which there is only 1 entry for each month of the period in
question. OwnerByMonth is a cross-tab query if that makes any
difference. At anyrate, I get the following error when I try to
execute this query:

The Microsoft Jet database engine does not recognise 'T1.[Month]' as a
valid field name or expression.

What am I missing?
 
G

Gary Walter

save results of your crosstab query
to a temp table, then run "running sum"
query on the temp table.

good luck,

gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Subquery help? 3
Year to Date subquery 3
Subquery 3
Subquery group by 4
Calculations using subquery 3
SubQuery Assistance... 1
Calculate 90th Percentile using top 10 percent 3
Urgent! Subquery help needed! 9

Top