当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在选择的情况下,如何检查字段问题的值是否为空?
发布于 2014-06-27 14:40:05
在与is比较时使用null运算符
case when n.ownerid is null then ...
when n.ownerid = '6e99ff04-f498-e311-93f3-005056a37b31' then ...
end as OwnerID发布于 2014-06-27 14:44:08
您还可以使用聚结表达式:
CASE when COALESCE(n.ownerid, '(nullVal)') = '(nullVal)' . . .https://stackoverflow.com/questions/24454524
复制相似问题