有更好的方法吗?
select count(First)+count(id)+count(Last)+count(Telephone)
from client
where id ="1";
答案 0 :(得分:1)
不确定这是否更好,但对于稍后阅读的人来说,意图可能会更清晰:
select
(case when First is null then 1 else 0 end) +
(case when id is null then 1 else 0 end) +
(case when Last is null then 1 else 0 end) +
(case when Telephone is null then 1 else 0 end)
from client
where id ="1";