我有一个包含 4 列的表,在第 5 列中我想存储前 4 列中有多少个非空列的计数。例如:
其中 X 是任意值:
Column1 | Column2 | Column3 | Column4 | Count
X | X | NULL | X | 3
NULL | NULL | X | X | 2
NULL | NULL | NULL | NULL | 0
select
T.Column1,
T.Column2,
T.Column3,
T.Column4,
(
select count(*)
from (values (T.Column1), (T.Column2), (T.Column3), (T.Column4)) as v(col)
where v.col is not null
) as Column5
from Table1 as T
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)