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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL calculated value Overflow prevention 2

Status
Not open for further replies.

techzone12

Technical User
Joined
Aug 24, 2005
Messages
32
Location
US
I have T-SQL query,in which I do a calculation as follows:

SELECT CONVERT(int,
Volts * Amps * 0.001732 * PF / 100)
AS KW
FROM Elec_Table

I want the query to check if the number calculated (KW) is higher that say 1000, then to produce a null or zero.

How do I do this?

Thanks
 
SELECT Case When CONVERT(int,
Volts * Amps * 0.001732 * PF / 100) > 1000
Then 0
Else CONVERT(int,
Volts * Amps * 0.001732 * PF / 100)
End AS KW
FROM Elec_Table


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
That did it.

Thanks a million!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top