Count null bit1 values : bit « Data Types « SQL Server / T-SQL Tutorial






5> CREATE TABLE T (
6>     int1 int,
7>     bit1 bit,
8>     varchar1 varchar(3),
9>     dec1 dec(5,2),
10>     cmp1 AS (int1 + bit1)
11> )
12> 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> SELECT COUNT(*) 'Count of null bit1'
2> FROM T
3> WHERE bit1 IS NULL
4> GO
Count of null bit1
------------------
                 2

(1 rows affected)
1>
2> drop table t;
3> GO
1>
2>








5.2.bit
5.2.1.bit type column
5.2.2.bit type column with default value
5.2.3.Count null bit1 values
5.2.4.Count non-null bit1 values