Solved

SELECT CASE NULL Comparison

Posted on 2008-10-08
4
888 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
ID: 22667324
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
ID: 22667333
CASE field WHEN...
just use for integer value
CASE field WHEN 1 then when 2.... end
0
 
LVL 4

Author Closing Comment

by:sublimation
ID: 31504158
Cheers!!!
0
 
LVL 7

Expert Comment

by:Chandan_Gowda
ID: 22667347
--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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql calculate averages 18 47
Need help debbuging stored procedure 21 32
subtract 1 in Access 2003 query 7 37
Need a starter for ETL protocol? 4 33
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…

914 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

14 Experts available now in Live!

Get 1:1 Help Now