SQLTeam.com | Weblogs | Forums

Mutiple replace condition


#1

hi

How do i replace values that is not of Y and N to NULL value when executing a select statement? For example Select Replace from tableA

here is my sample data.

ColA ColB ColC
N Y N
N Y Y
Y N 12M
N 0 0
118 NULL NULL
20 NULL 5
HN 12K NULL

Thanks a lot


#2
SELECT CASE WHEN ColA NOT IN ('Y', 'N') THEN NULL ELSE ColA END
FROM   tableA

#3

Thank you so much khtan