Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Using ISNULL in CASE statement

$
0
0

Hi,

I need to write a query that will gimme the resultsets based on a data comparison with some values, Those values that are null in the result set needs to be replaced with an empty string which can be obtained using ISNULL function. My question here is, how to incorporate this in a SELECT statement that has CASE expression. I coded some thing like this but the result set for the column is returning zero instead of an empty string. The data type for this column ABC is varchar(10)

SELECT top 20
        ABC
	   ,CASE 
        WHEN ABC IN (8,9,10,13,14,15,16,17,19,20,21) THEN 10
		WHEN ABC IN (31,32,33) THEN 30
		WHEN ABC IN (53,52,54,55) THEN 50
		WHEN ABC IN (61,62) THEN 60
		WHEN (ABC IS NULL AND DEF IS NOT NULL) THEN 99
		else ISNULL(ABC,'')
		END
FROM XYZ 

Any help is appreciated

Many Thanks,

Bhanu



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>