Solved

SELECT CASE NULL Comparison

Posted on 2008-10-08
4
896 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

623 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