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

Home
SQL Server / T-SQL Tutorial
1.Query
2.Insert Delete Update
3.Table
4.Table Join
5.Data Types
6.Set Operations
7.Constraints
8.Subquery
9.Aggregate Functions
10.Date Functions
11.Math Functions
12.String Functions
13.Data Convert Functions
14.Analytical Functions
15.Sequence Indentity
16.View
17.Index
18.Cursor
19.Database
20.Transact SQL
21.Procedure Function
22.Trigger
23.Transaction
24.XML
25.System Functions
26.System Settings
27.System Tables Views
28.User Role
29.CLR
SQL Server / T-SQL Tutorial » Data Types » bit 
5.2.4.Count non-null bit1 values
7CREATE 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>
2INSERT (int1, bit1VALUES (10)
3INSERT (int1, varchar1VALUES (2'abc')
4INSERT (int1, dec1VALUES (35.25)
5INSERT (bit1, dec1VALUES (19.75)
6> GO

(rows affected)

(rows affected)

(rows affected)

(rows affected)
1>
2SELECT COUNT(*'Count of non-null bit1'
3FROM T
4WHERE bit1 IS NOT NULL
5> GO
Count of non-null bit1
----------------------
                     2

(rows affected)
1>
2> drop table t;
3> GO
1>
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.