Count the Null columns in a row in SQL

后端 未结 13 769
小蘑菇
小蘑菇 2020-11-30 04:36

I was wondering about the possibility to count the null columns of row in SQL, I have a table Customer that has nullable values, simply I want a query that return an int of

13条回答
  •  悲&欢浪女
    2020-11-30 05:34

    This will give you the number of columns which are not null. you can apply this appropriately

    SELECT   ISNULL(COUNT(col1),'') + ISNULL(COUNT(col2),'') +ISNULL(COUNT(col3),'') 
       FROM TABLENAME
       WHERE  ID=1
    

提交回复
热议问题