Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CASE statement IS NULL

Posted on 2008-11-04
3
Medium Priority
?
340 Views
Last Modified: 2011-10-03
Trying to place a CASE when a value IS NULL than make it 0 but I think I have some syntax error.

CASE B.MILEAGE WHEN IS NULL THEN '0' END AS GPS_ODOM
0
Comment
Question by:chrisryhal
3 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 1000 total points
ID: 22876663
CASE  WHEN B.MILEAGE IS NULL THEN '0' END AS GPS_ODOM
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 22876664
this is it:
CASE WHEN B.MILEAGE IS NULL THEN '0' END AS GPS_ODOM 
or: 
COALESCE(B.MILEAGE , '0')

Open in new window

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 22876666
Hello chrisryhal,

Case When B.Mileage Is Null Then '0' Else B.Mileage End As GPD_ODOM

Or simply

IsNull(B.Mileage,'0') As GPS_ODOM

Regards,

TimCottee
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Loops Section Overview
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

577 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