all values less than 0 to equal 0 or null

G

Guest

I am trying to calculate the sum of the cost but the data I have has negative
values that in this particular instance I do not want to count in my total
cost. Is there a way to write an If Than statment that will make all of the
negative values equal zero or not be counted at all when I make cost grouped
by SUM?
 
D

David Lloyd

Kathryn:

IIF([Cost]>=0,[Cost],0)

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I am trying to calculate the sum of the cost but the data I have has
negative
values that in this particular instance I do not want to count in my total
cost. Is there a way to write an If Than statment that will make all of the
negative values equal zero or not be counted at all when I make cost grouped
by SUM?
 
D

Dale Fye

Add a where clause between your select and the Group By portion of the SQL.

WHERE [Cost] > 0

HTH
Dale
 
G

Guest

I would try something along the lines of
Sum(IIf(myCol<0,0,myCol))

Hope This Helps
Gerald Stanley MCSD
 

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