当n.ownerid为null时,它将永远不会执行此部分:
...........,case n.ownerid
when NULL then
(
select systemuserid
from crm_systemuserbase
where firstname = 'CRM' and lastname='Admin'
)...........
以下是更多周边代码:
,case n.ownerid
when NULL then
(
select systemuserid
from crm_systemuserbase
where firstname = 'CRM' and lastname='Admin'
)
when '6e99ff04-f498-e311-93f3-005056a37b31' then
(
select systemuserid
from crm_systemuserbase
where firstname = 'CRM' and lastname='Admin'
)
end as OwnerID
在SELECT CASE中如何检查字段问题的值是否为空?
答案 0 :(得分:7)
与is
null
运算符
case when n.ownerid is null then ...
when n.ownerid = '6e99ff04-f498-e311-93f3-005056a37b31' then ...
end as OwnerID
答案 1 :(得分:2)
你也可以使用COALESCE表达式:
CASE when COALESCE(n.ownerid, '(nullVal)') = '(nullVal)' . . .