Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Anzahl der Nicht-Null-Spalten in jeder Zeile

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