我在SQL Developer中使用以下CASE语句:
CASE
WHEN ([Medication]="N") AND ([Name]="STYMES") AND ([Original Units] IS NOT NULL) THEN "Y"
WHEN ([Medication]="N") AND ([Name]="STYMES") AND ([Original Units] IS NULL) THEN "N"
WHEN ([Medication]="Y") AND ([Name]="STYMES") AND ([Original Units] IS NOT NULL) THEN "N"
WHEN ([Medication]="Y") AND ([Name]="STYMES") AND ([Original Units] IS NULL) THEN "Y"
END
当我至少得到N
时,我的结果是空的。
答案 0 :(得分:1)
如果你想要的只是得到一个N'当您的其他条件不满足时,您可以使用ELSE关键字,如:
case
when ([Medication]="N") AND ([Name]="STYMES") AND([Original Units] is not null) then "Y"
when ([Medication]="N") AND ([Name]="STYMES") AND([Original Units] is null) then "N"
when ([Medication]="Y") AND ([Name]="STYMES") AND([Original Units] is not null) then "N"
when ([Medication]="Y") AND ([Name]="STYMES") AND([Original Units] is null) then "Y"
else "N"
end