473,385 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Subtracting select queries form each other (each select query has multiple conditions)

How do i subtract the first value from the second value without
multiple queries? (query example below)

SELECT Sum(tbl_Area_PropLend.Amount) AS Default_FinCharge
FROM tbl_Area_PropLend
GROUP BY tbl_Area_PropLend.ReportingMonth, tbl_Area_PropLend.Measure,
tbl_Area_PropLend.Type
HAVING (((tbl_Area_PropLend.ReportingMonth)=#8/1/2004#) AND
((tbl_Area_PropLend.Measure)=1) AND ((tbl_Area_PropLend.Type)=2));

SELECT Sum(tbl_Area_PropLend.Amount) AS DefaultADB
FROM tbl_Area_PropLend
GROUP BY tbl_Area_PropLend.ReportingMonth, tbl_Area_PropLend.Measure,
tbl_Area_PropLend.Type
HAVING (((tbl_Area_PropLend.ReportingMonth)=#8/1/2004#) AND
((tbl_Area_PropLend.Measure)=2) AND ((tbl_Area_PropLend.Type)=2));

Feb 25 '06 #1
1 2279
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Like this:

SELECT Sum(IIf([Measure]=1,Amount,0)) AS Default_FinCharge,
Sum(IIf([Measure]=2,Amount,0)) As DefaultADB,
Sum(IIf([Measure]=2,Amount,0))-Sum(IIf([Measure]=1,Amount,0)) As
Difference
FROM tbl_Area_PropLend
WHERE ReportingMonth=#8/1/2004#
AND [Measure] IN (1,2)
AND [Type]=2
GROUP BY ReportingMonth, [Measure], [Type]

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAIXa4echKqOuFEgEQLZSgCcDP+eY+Z/Bjf3zGZnP7dI8WyPP0IAn2tp
yRc1UwsUBvuXowOaHPSCokgf
=CREf
-----END PGP SIGNATURE-----
Wo************@gmail.com wrote:
How do i subtract the first value from the second value without
multiple queries? (query example below)

SELECT Sum(tbl_Area_PropLend.Amount) AS Default_FinCharge
FROM tbl_Area_PropLend
GROUP BY tbl_Area_PropLend.ReportingMonth, tbl_Area_PropLend.Measure,
tbl_Area_PropLend.Type
HAVING (((tbl_Area_PropLend.ReportingMonth)=#8/1/2004#) AND
((tbl_Area_PropLend.Measure)=1) AND ((tbl_Area_PropLend.Type)=2));

SELECT Sum(tbl_Area_PropLend.Amount) AS DefaultADB
FROM tbl_Area_PropLend
GROUP BY tbl_Area_PropLend.ReportingMonth, tbl_Area_PropLend.Measure,
tbl_Area_PropLend.Type
HAVING (((tbl_Area_PropLend.ReportingMonth)=#8/1/2004#) AND
((tbl_Area_PropLend.Measure)=2) AND ((tbl_Area_PropLend.Type)=2));

Feb 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
0
by: MHenry | last post by:
Hi, I know virtually nothing about creating Macros in Access. I would appreciate some help in creating a Macro or Macros that automatically run(s) 14 Queries (three Make Table Queries, and 11...
3
by: matthewemiclea | last post by:
I am trying to display information in Access on a form that takes information from many different queries and puts them together on a spreadsheet or chart. Some specific info: The information I...
0
by: rayone | last post by:
Hi folks. I need advice. 2 options, which do you think is the better option to display/retrieve/report on the data. Keep in mind reporting (Crystal), SQL Performance, VB Code, usability,...
0
by: Christoph Haas | last post by:
Hi, list... I have written an application in Perl some time ago (I was young and needed the money) that parses multiple large text files containing nested data structures and allows the user to...
6
by: Joe | last post by:
Hi, I’ve lurked for a bit and certainly hope you folks can be as much help to me as you have been to others. My problem is basically trying to query several results in a single field (“or” type)...
3
by: swb76 | last post by:
Hi, I have 6 queries in Access that run great. They need to be run in sequence with the first 5 queries writing to tables and the sixth one pops up the final results in datasheet view. Now, how...
4
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.