A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Subtract positive number from negative number



 
 
Thread Tools Display Modes
  #1  
Old July 4th, 2008, 02:42 AM posted to microsoft.public.access.queries
Brett[_2_]
external usenet poster
 
Posts: 25
Default Subtract positive number from negative number

I have a query similar to this:

SELECT Sales.ThisYear - Sales.LastYear AS SalesDifference
FROM ThisYear, LastYear;

This works fine if they are both positive. However, I have an instance
where the sales for this year is negative and last year is positive:

ThisYear: -80,000
LastYear: 20,000

Result in Access: -100,000 when it should be -60,000.

So how can I get it to subtract a positive number from a negative
number?
  #2  
Old July 4th, 2008, 02:56 AM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Subtract positive number from negative number

What kind of business rule would result in -60,000 rather than the correct
-100,000?

--
Duane Hookom
Microsoft Access MVP


"Brett" wrote:

I have a query similar to this:

SELECT Sales.ThisYear - Sales.LastYear AS SalesDifference
FROM ThisYear, LastYear;

This works fine if they are both positive. However, I have an instance
where the sales for this year is negative and last year is positive:

ThisYear: -80,000
LastYear: 20,000

Result in Access: -100,000 when it should be -60,000.

So how can I get it to subtract a positive number from a negative
number?

  #3  
Old July 4th, 2008, 03:04 AM posted to microsoft.public.access.queries
Brett[_2_]
external usenet poster
 
Posts: 25
Default Subtract positive number from negative number

That was just an example. You could have the first month of the year
with a credit on account and comparing that with the first month of
last year, you have this scenario. So instead of analyzing this in
terms of business, can you answer my question?

Essentially, what I am looking for is a Variance function of some sort
that will show the difference between two numbers, does it exist?
  #4  
Old July 4th, 2008, 03:17 AM posted to microsoft.public.access.queries
Brett[_2_]
external usenet poster
 
Posts: 25
Default Subtract positive number from negative number

Never mind...I'm using the Abs() function and it worked.
  #5  
Old July 4th, 2008, 10:11 AM posted to microsoft.public.access.queries
scubadiver
external usenet poster
 
Posts: 1,673
Default Subtract positive number from negative number


Not wishing to incur your wrath further I don't understand why you have
negative sales ???

"Brett" wrote:

I have a query similar to this:

SELECT Sales.ThisYear - Sales.LastYear AS SalesDifference
FROM ThisYear, LastYear;

This works fine if they are both positive. However, I have an instance
where the sales for this year is negative and last year is positive:

ThisYear: -80,000
LastYear: 20,000

Result in Access: -100,000 when it should be -60,000.

So how can I get it to subtract a positive number from a negative
number?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.