[Solved] Count the number of existing values in a field in a record [closed]


Use CASE expressions to count each column.

SELECT
    CASE WHEN Column1 IS NOT NULL THEN 1 ELSE 0 END
    + CASE WHEN Column2 IS NOT NULL THEN 1 ELSE 0 END
    -- repeat for all columns
    AS NumberOfNonNullColumns
FROM MyTable

3

solved Count the number of existing values in a field in a record [closed]