Mega Code Archive

 
Categories / MSSQL Tutorial / Data Types
 

Count non-null bit1 values

7>  CREATE TABLE T ( 8>     int1 int, 9>     bit1 bit, 10>     varchar1 varchar(3), 11>     dec1 dec(5,2), 12>     cmp1 AS (int1 + bit1) 13> ) 14> GO 1> 2> INSERT T (int1, bit1) VALUES (1, 0) 3> INSERT T (int1, varchar1) VALUES (2, 'abc') 4> INSERT T (int1, dec1) VALUES (3, 5.25) 5> INSERT T (bit1, dec1) VALUES (1, 9.75) 6> GO (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) 1> 2> SELECT COUNT(*) 'Count of non-null bit1' 3> FROM T 4> WHERE bit1 IS NOT NULL 5> GO Count of non-null bit1 ----------------------                      2 (1 rows affected) 1> 2> drop table t; 3> GO 1>