当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中,如何检查字段问题的值是否为null?
最佳答案
与is
比较时使用null
运算符
case when n.ownerid is null then ...
when n.ownerid = '6e99ff04-f498-e311-93f3-005056a37b31' then ...
end as OwnerID