我使用的是始终加密的,无法使用IsNull或LEN功能。我想用case和IS NULL或IS NOT NULL来实现它。
有人可以告诉我如何使用CASE和IS NULL / IS NOT NULL重写下面的逻辑吗?
$ sudo ssh-add -k
[sudo] Password for myuser:
Could not open a connection to your authentication agent.
更新2:
Len(IsNull(c.email1, IsNull(e.email,ORG_Email))) <> 0
答案 0 :(得分:3)
我会把它写成:
len(coalesce(c.email1, e.email, org_email)) <> 0
但你可能遇到同样的问题。因此,使用case
和is null
的问题的答案是:
(case when c.email1 is null and e.email is null and org_email is null
then 0 -- all are missing
else 1
end) = 1
我不喜欢case
子句中的where
语句,所以更好的答案是更简单的表达式:
(c.email1 is not null or e.email is not null or org_email is not null)
这是表达逻辑的正确方法。
答案 1 :(得分:0)
case when c.email1 is not null then c.email1
when e.email is not null then c.email
else ORG_Email end
如果你想要的只是确定是否存在电子邮件:
case when c.email1 is not null then 1
when e.email is not null then 1
when ORG_Email is not null then 1 else 0 end
或合并案例
case when c.email1 is not null Or e.email is not null Or
ORG_Email is not null then 1 else 0 end