Subracting One SQL Query from another SQL Query

G

Guest

I have a table with various data, I need to make calculations of this data in
many ways. I currently have two queries that are doing a count of the data
shown below and I want to subtract one from the other for a seperate query
for a report. Any ideas?

Query 1
SELECT COUNT(*) AS CompletedSubmittedIA
FROM [Test RFC Log]
WHERE (([Test RFC Log].DateRMCompletedIAforFinance)>=#1/1/2001#);

Query 2
SELECT COUNT(*) AS IASubmittedtoEDS
FROM [Test RFC Log]
WHERE ((([Test RFC Log].DateIssuedtoEDS)>=#1/1/2001#));

Many thanks for any help

Chris
 
J

Jamie Collins

Pikku said:
I currently have two queries that are doing a count of the data
shown below and I want to subtract one from the other for a seperate query
for a report. Any ideas?

Query 1
SELECT COUNT(*) AS CompletedSubmittedIA
FROM [Test RFC Log]
WHERE (([Test RFC Log].DateRMCompletedIAforFinance)>=#1/1/2001#);

Query 2
SELECT COUNT(*) AS IASubmittedtoEDS
FROM [Test RFC Log]
WHERE ((([Test RFC Log].DateIssuedtoEDS)>=#1/1/2001#));

SELECT Query2.IASubmittedtoEDS - Query1.CompletedSubmittedIA
AS result
FROM Query1, Query2;

Jamie.

--
 
G

Guest

In a text field control source in the report you can write.

=Dlookup("CompletedSubmittedIA","Query1") -
Dlookup("IASubmittedtoEDS","Query2")

Or, instead of using two queries you can write
=Dcount("*","[Test RFC Log]","[DateRMCompletedIAforFinance])>=#1/1/2001#") -
Dcount("*","[Test RFC Log]","[DateIssuedtoEDS])>=#1/1/2001#")
 
J

John Spencer

How about one query?

SELECT Abs(Sum(DateRMCompletedIAforFinance>=#1/1/2001#)) -
Abs(Sum(DateIssuedtoEDS>=#1/1/2001#)) as MyDiff
FROM [TEST RFC LOG]
WHERE [Test RFC Log].DateRMCompletedIAforFinance>=#1/1/2001#
OR [Test RFC Log].DateIssuedtoEDS)>=#1/1/2001#

Or you can use the DCount function mentioned elsewhere in this thread.
 

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