Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning a negative number into 0

Status
Not open for further replies.

DebbieChapman

Programmer
May 25, 2003
26
GB
How can i turn a negative number (ie -43) in 0 in SQL 7. I've tried using the round function but am not getting anywhere.

In my view grid i want any negatives to return a 0
 
select IDClient, CASE WHEN Job_Hour < 0 Then 0 ELSE Job_Hour END
from Job_Transac

Thanks

J. Kusch
 
Sorry ... That was from my test table. Maybe This may be a little clearer

select MyField1,
MyField2,
CASE
WHEN MyField3 < 0
THEN 0
ELSE MyField3
END
from MyTable

Thanks

J. Kusch
 
what is MyField3 Defined as? Also, I would give the 3rd record returned a Name...

select MyField1,
MyField2,
CASE WHEN MyField3 < 0 THEN 0 ELSE MyField3 END AS MyField3

from MyTable

DLC
 
Ok I see the code...what was the error?


Hope I've been helpful,
Wayne Francis

If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top