SELECT CASE NULL Comparison

Hi,

SELECT CASE field WHEN NULL THEN 'no' ELSE 'yes' FROM myTable

This sql statement gives me all 'yes' although there are many NULLS in the table.  Expect to see those 'no' values. Something very basic here!!

Please help.

LVL 4
sublimationAsked:
Who is Participating?
 
HuyBDConnect With a Mentor Commented:
try this

SELECT CASE WHEN field is NULL THEN 'no' ELSE 'yes' FROM myTable

Open in new window

0
 
HuyBDCommented:
CASE field WHEN...
just use for integer value
CASE field WHEN 1 then when 2.... end
0
 
sublimationAuthor Commented:
Cheers!!!
0
 
Chandan_GowdaCommented:
--End should be added for the above query
SELECT CASE WHEN field is NULL THEN 'no' ELSE 'yes' END AS field FROM myTable
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.