add with null

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I have two int fields of a table: Count1 and Count2
I select with the sql:

Select Count1+Count2 as CountSum form myTable


When one filed have a value and the other with null, the CountSum will be
null.
I wnat to treate the null value as 0 int, So I want to 2+ null=2

How can I do?
 
SELECT (Count1 +
(CASE WHEN Count2 IS NULL THEN 0
ELSE Count2 END))
FROM myTable

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
Back
Top