2016-08-03 5 views
-1

私は常に暗号化を使用しており、IsNullまたはLEN関数を使用することはできませんでした。私は大文字小文字を使用したい、それを達成するためにNULLまたはIS NOT NULLを使用します。IsNullとLENをCaseとIS NULLに置き換える

CASEとIS NULL/IS NOT NULLを使用して、以下のロジックを書き直す方法を教えてもらえますか?

Len(IsNull(c.email1, IsNull(e.email,ORG_Email))) <> 0 

アップデート2:

case when email_indicator != 'N' and Len(IsNull(c.email1, IsNull(e.email,ORG_Email))) <> 0 

Then 'E' else 'N' End 

答えて

3

私はこのように記述します。

len(coalesce(c.email1, e.email, org_email)) <> 0 

しかし、あなたはおそらく、同じ問題を抱えています。だから、caseis 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 

私はwhere句でcase文を好きではないので、より良い答えは単純式です:

(c.email1 is not null or e.email is not null or org_email is not null) 

これは本当にあります論理を表現する正しい方法。

+0

を組み合わせを、どのような場合にはメールの1つがヌルではありませんか? – HadoopAddict

+0

質問の更新を追加しました。私は本当にそれを達成しようとしています。 – HadoopAddict

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 
+0

質問の更新を追加しました。私は本当にそれを達成しようとしています – HadoopAddict

関連する問題