Solved

SELECT CASE NULL Comparison

Posted on 2008-10-08
4
885 Views
Last Modified: 2012-06-27
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.

0
Comment
Question by:sublimation
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
HuyBD earned 250 total points
Comment Utility
try this

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

Open in new window

0
 
LVL 17

Expert Comment

by:HuyBD
Comment Utility
CASE field WHEN...
just use for integer value
CASE field WHEN 1 then when 2.... end
0
 
LVL 4

Author Closing Comment

by:sublimation
Comment Utility
Cheers!!!
0
 
LVL 7

Expert Comment

by:Chandan_Gowda
Comment Utility
--End should be added for the above query
SELECT CASE WHEN field is NULL THEN 'no' ELSE 'yes' END AS field FROM myTable
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now