clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1044276 fiddles created (9441 in the last week).

CREATE TABLE TestTable (id nvarchar(20),Field_1 nvarchar(20),Field_2 nvarchar(20),Field_3 nvarchar(20));
 hidden batch(es)


INSERT INTO TestTable SELECT id= '1',Field_1 = '20' ,Field_2 =null ,Field_3='21' INSERT INTO TestTable SELECT id= '2',Field_1 = null ,Field_2 =null ,Field_3=null INSERT INTO TestTable SELECT id= '3',Field_1 = '12' ,Field_2 ='13' ,Field_3='15'
3 rows affected
 hidden batch(es)


SELECT * FROM TestTable
id Field_1 Field_2 Field_3
1 20 21
2
3 12 13 15
 hidden batch(es)


select id,Field_1,Field_2,Field_3, Field_1T+Field_2T+Field_3T as CountNull from ( select id,Field_1,Field_2,Field_3, case when Field_1 is null then 1 else 0 end as Field_1T, case when Field_2 is null then 1 else 0 end as Field_2T, case when Field_3 is null then 1 else 0 end as Field_3T from TestTable where 1=1 and not (Field_1 is not null and Field_2 is not null and Field_3 is not null) ) as TempTable where 1=1 union select id,Field_1,Field_2,Field_3,0 as CountNull from TestTable where 1=1 and Field_1 is not null and Field_2 is not null and Field_3 is not null order by id
id Field_1 Field_2 Field_3 CountNull
1 20 21 1
2 3
3 12 13 15 0
 hidden batch(es)