我有这个查询。 我想要 获取日期范围内的记录 - > DONE 获取PriorSurgery ='是'的记录 - > DONE 得到顾问不是空白的记录 - 不工作
如何测试无空白。
我试过AND adm.adm_Consultant != ''
我已经AND adm.adm_Consultant <> ''
以下一个(看起来更好的方式)
我哪里错了?
SELECT adm.adm_Consultant, adm.adm_PriorSurgery
FROM Admission adm
WHERE adm.adm_ReferralDate >= '01/01/2014 00:00:00' AND adm.adm_ReferralDate <= '31/12/2014 00:00:00'
AND adm.adm_PriorSurgery = 'Yes',
AND LENGTH(adm.adm_Consultant) > 0
答案 0 :(得分:1)
如果值为null,则
SELECT adm.adm_Consultant, adm.adm_PriorSurgery
FROM Admission adm
WHERE adm.adm_ReferralDate >= '01/01/2014 00:00:00' AND adm.adm_ReferralDate <= '31/12/2014 00:00:00'
AND adm.adm_PriorSurgery = 'Yes'
AND adm.adm_Consultant IS NOT NULL