Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2006

Tip: Looking for answers? Try searching our database.

Subracting One SQL Query from another SQL Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pikku Apina - 31 May 2006 10:46 GMT
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
Jamie Collins - 31 May 2006 11:51 GMT
> 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
[quoted text clipped - 9 lines]
> FROM [Test RFC Log]
> WHERE ((([Test RFC Log].DateIssuedtoEDS)>=#1/1/2001#));

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

Jamie.

--
Ofer Cohen - 31 May 2006 12:16 GMT
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#")

Signature

Good Luck
BS"D

> 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
[quoted text clipped - 14 lines]
>
> Chris
John Spencer - 31 May 2006 13:08 GMT
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.

>I have a table with various data, I need to make calculations of this data
>in
[quoted text clipped - 15 lines]
>
> Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.