Sum of a UNION Query

  • Follow


Hello,

I want to sum the values together that are returned from the following
two queries joined with a UNION from within the same query (instead of
creating a second query that will SUM the two values that are produced
from this one).  I tried "wrapping" this code within a SELECT SUM, but
it returns with "this is not allowing in subqueries".

SELECT Count(*) AS SubCount
FROM [TABLE1]
WHERE (([TABLE1].USER)="JOHNSMITH")
UNION ALL SELECT Count(*) AS SubCount
FROM [TABLE2]
WHERE (([TABLE2].USER)="EJONES");

The results are:

SubCount
--------------
380
45

But, as I mentioned, from with the same query I want the following:

SubCount
--------------
425

Any ideas?

Thanks in Advance!

0
Reply Hendy88 5/21/2007 9:23:41 PM


0 Replies
303 Views

(page loaded in 0.009 seconds)

Similiar Articles:
















7/27/2012 1:40:57 PM


Reply: