Sum of Two Union Queries

H

Hendy88

Hello,

I have the following SQL that produces two record totals (as it
should). But I want to SUM those two values from within the same
query. Rather than create a second query that SUMs the two values
from the first query:

SELECT Count(*) AS SubCount
FROM [MyTable1]
WHERE (([MyTable1].UNIQUEUSER)="JOHNSMITH")
UNION ALL SELECT Count(*) AS SubCount
FROM [MyTable2]
WHERE (([MyTable2].SWCASSIGNEDUSER)="JOHNSMITH");

The results I get are:

SubCount
--------------
380
2


I've tried "wrapping" that entire SQL code inside of a SELECT SUM, but
upon execution it says, "this operation is not allowed in subqueries".

Any ideas?

Thanks in advance!
 

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

Top