SUM query

IxiRancid

Well-known member
Joined
Jun 16, 2004
Messages
104
Location
Europe
Hi,
Im having some troubles with a SUM query in Access.
How can I sum all values of a field in EVERY table named "amount_cur" by a parameter that I pass?

I tried with
SELECT SUM amount FROM table1, table2, table3
just to begin with the SUM, and then pass the WHERE clause but this didnt work as if "multiple cells found in tables" stuff.
 
you mean something like this. . .


SELECT Sum(total) AS GrandTotal FROM
(
SELECT Sum(amount) AS total
FROM table1
union all
SELECT Sum(amount) AS total
FROM table2
union all
SELECT Sum(amount) AS total
FROM table3
)
 
SUM is a group by function. what actually you are intended to do i did not get. if you want to get sum for all table as seperate record then use it in following way

select sum(urvalue), groupfield from urtable group by groupfield
union
select sum(urvalue), groupfield from urtable1 group by groupfield
:rolleyes:
 
Joe Mamma said:
you mean something like this. . .


SELECT Sum(total) AS GrandTotal FROM
(
SELECT Sum(amount) AS total
FROM table1
union all
SELECT Sum(amount) AS total
FROM table2
union all
SELECT Sum(amount) AS total
FROM table3
)


This would be it, I believe. Ill try it.
Thanks!
 
Back
Top