Solved

Can I Sum and Subtract In One SQL Statement?

Posted on 2013-12-10
3
482 Views
Last Modified: 2013-12-10
I am using Dreamweaver with ASP.
I have three fields where I have to sum two fields and then subtract the total from the third field. (Customer1 + Customer2) then subtract from Total Inv$

The select statement I think, would be something like this, BUT this one DOES NOT work.

SELECT SUM(Total Inv$)-(Sum(Customer1+Customer2))
WHERE Date=Date()

Any way of doing this?

Thank you...
Rick
0
Comment
Question by:ES-Components
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39709752
How is it not working ... wrong results or error?

Try this (use brackets around fields containing spaces or special characters).  I'm assuming all these fields are numeric:


SELECT SUM([Total Inv$])-(Sum(Customer1) + Sum(Customer2))
WHERE Date=Date()

Open in new window

0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39709761
select field3 - (field1+field2) from mytable

This will give you the result in each row of the table. If you need the total of it all, then

select sum(field3 - (field1+field2) ) from mytable
0
 

Author Closing Comment

by:ES-Components
ID: 39709822
I did get this to work.
Thank you for your quick response.

Rick
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question