select id,userid, ys,
case pj_ys
when NULL
then ( case pj_ys1 when NUll then ys else pj_ys1 end)
else pj_ys end t
from dbo.tbl_Emplyeeblogs
但是发现结果是错的。因为case when 判断null并不是这么判断的,需要注意判断null是用case when pj_ys is null then下面是代码:
select id,userid, ys,
case
when pj_ys is NULL
then ( case when pj_ys1 is NUll then ys else pj_ys1 end)
else pj_ys end t
from dbo.tbl_Emplyeeblogs