If Result < 0 Then Print 0

drogerson

New member
Local time
Today, 16:01
Joined
Oct 17, 2011
Messages
6
Hi,

I have written a select query that provides me with a numerical result. However, I would like the Result to never be less than 0.

Is it possible to end a select query with some form of IF statement that would print "0" if the result was negative?
 
Difficult to be precise with the info given but

Calcfield: Iif(calculation<0,0,calculation)

Brian
 
Sorry, I'll try and clear it up a little.

SELECT table1.NUMBER, table1.NUMNAME, table1.NAME, table1.Value1, table2.Value2, table2.Value3, ([[Value2]-([Value1]*[Value3])) AS RATING
FROM table1, table2
WHERE ((table1.NUMBER)=[table2.NUMBER]);

Basically "Rating" can be calculated to less than 0, but if it is should only show 0.
 
That's the code that Brian gave you. Rating is a calculation, so simply replace the word calculation in the code provided by the calculation in Rating.

Or use the Format() function (for Numbers) and specify what the Negative parameter should display.
 

Users who are viewing this thread

Back
Top Bottom