0
我寫了下面的查詢來檢查重複項。檢查空列值的情況下,並忽略它們
select s.*,m.IsMember_Ind,
case when REPLACE(s.[ Owner Mobile],' ','')
in (select cd.Mobile
from Company_Detail cd
inner join MEMBERSHIP m
on cd.Company_ID = m.Company_ID
where m.IsMember_Ind = 1)
then 'Match'
else ' ' end as OwnerMobileMatch,
case when REPLACE(s.[ Contact Number],' ','')
in (select cd.Mobile
from Company_Detail cd
inner join MEMBERSHIP m
on cd.Company_ID = m.Company_ID
where m.IsMember_Ind = 1)
then 'Match' else ' ' end as ContactMobileMatch
from COMPANY c
inner join surreynonmembers s
on c.TTR_ID = s.[Company ID]
left outer join MEMBERSHIP m
on m.Company_ID = c.Company_ID
我的問題是,case語句返回匹配時發現一個空值,我不需要。如果只有一個值,我該如何修改這個查詢來返回?
爲什麼不只是使用另一種情況,或者如果使用ISNULL()函數呢? – sdrzymala 2015-02-06 13:56:24
或者在ContactMobileMatch中包含'AND'S。[Owner Mobile] <>'''在OwnerMobileMatch和'AND s。[Contact Number] <>'''中。 – Tom 2015-02-06 21:44:40