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!

Question about CAST function 1

Status
Not open for further replies.

mrDrive

MIS
Aug 29, 2002
94
US
Hi,

I have a query that adds together a number of bit fields together to basically give me the "number of true values" for a record:

Code:
select field1, field2, cast(bol_field1 as int) + cast(bol_field2 as int) as trueCount
from myTable

My problem is that either bol_field1 or bol_field2 can be null. So when one of them is null, the "trueCount" alias returns null.

Is there a way to make bol_field1 = 0 or bol_field2 = 0 if they're in fact null?

Thanks for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top