You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns the number of items in a group. COUNT_BIG works like the COUNT function. The only difference between the two functions is their return values. COUNT_BIG always returns a **bigint** data type value. COUNT always returns an **int** data type value.
36
+
This function returns the number of items found in a group. `COUNT_BIG` operates like the [COUNT](../../t-sql/functions/count-transact-sql.md) function. These functions differ only in the data types of their return values. `COUNT_BIG` always returns a **bigint** data type value. `COUNT` always returns an **int** data type value.
37
37
38
38
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
Applies the aggregate function to all values. ALL is the default.
61
+
Applies the aggregate function to all values. ALL serves as the default.
62
62
63
63
DISTINCT
64
-
Specifies that COUNT_BIG returns the number of unique nonnull values.
64
+
Specifies that `COUNT_BIG` returns the number of unique nonnull values.
65
65
66
66
*expression*
67
-
Is an [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type. Aggregate functions and subqueries are not permitted.
67
+
An [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type. Note that `COUNT_BIG` does not support aggregate functions or subqueries in an expression.
68
68
69
69
*\**
70
-
Specifies that all rows should be counted to return the total number of rows in a table. COUNT_BIG(*\**) takes no parameters and cannot be used with DISTINCT. COUNT_BIG(*\**) does not require an *expression* parameter because, by definition, it does not use information about any particular column. COUNT_BIG(*\**) returns the number of rows in a specified table without getting rid of duplicates. It counts each row separately. This includes rows that contain null values.
71
-
72
-
ALL
73
-
Applies the aggregate function to all values. ALL is the default.
74
-
75
-
DISTINCT
76
-
Specifies that AVG be performed only on each unique instance of a value, regardless of how many times the value occurs.
77
-
78
-
*expression*
79
-
Is an [expression](../../t-sql/language-elements/expressions-transact-sql.md) of the exact numeric or approximate numeric data type category, except for the **bit** data type. Aggregate functions and subqueries are not permitted.
70
+
Specifies that `COUNT_BIG` should count all rows to determine the total table row count to return. `COUNT_BIG(*)` takes no parameters and does not support the use of DISTINCT. `COUNT_BIG(*)` does not require an *expression* parameter because by definition, it does not use information about any particular column. `COUNT_BIG(*)` returns the number of rows in a specified table, and it preserves duplicate rows. It counts each row separately. This includes rows that contain null values.
80
71
81
72
OVER **(**[*partition_by_clause*][*order_by_clause*]**)**
82
-
*partition_by_clause* divides the result set produced by the FROM clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group. *order_by_clause* determines the logical order in which the operation is performed. For more information, see [OVER Clause (Transact-SQL)](../../t-sql/queries/select-over-clause-transact-sql.md).
73
+
The *partition_by_clause* divides the result set produced by the `FROM` clause into partitions to which the `COUNT_BIG`function is applied. If not specified, the function treats all rows of the query result set as a single group. The *order_by_clause* determines the logical order of the operation. See [OVER Clause (Transact-SQL)](../../t-sql/queries/select-over-clause-transact-sql.md) for more information.
83
74
84
75
## Return types
85
76
**bigint**
86
77
87
78
## Remarks
88
-
COUNT_BIG(*) returns the number of items in a group. This includes NULL values and duplicates.
79
+
COUNT_BIG(\*) returns the number of items in a group. This includes NULL values and duplicates.
89
80
90
-
COUNT_BIG (ALL *expression*) evaluates *expression* for each row in a group and returns the number of nonnull values.
81
+
COUNT_BIG (ALL *expression*) evaluates *expression* for each row in a group, and returns the number of nonnull values.
91
82
92
-
COUNT_BIG (DISTINCT *expression*) evaluates *expression* for each row in a group and returns the number of unique, nonnull values.
83
+
COUNT_BIG (DISTINCT *expression*) evaluates *expression* for each row in a group, and returns the number of unique, nonnull values.
93
84
94
-
COUNT_BIG is a deterministic function when used without the OVER and ORDER BY clauses. It is nondeterministic when specified with the OVER and ORDER BY clauses. For more information, see [Deterministic and Nondeterministic Functions](../../relational-databases/user-defined-functions/deterministic-and-nondeterministic-functions.md).
85
+
COUNT_BIG is a deterministic function when used ***without*** the OVER and ORDER BY clauses. It is nondeterministic when used ***with*** the OVER and ORDER BY clauses. See [Deterministic and Nondeterministic Functions](../../relational-databases/user-defined-functions/deterministic-and-nondeterministic-functions.md) for more information.
95
86
96
87
## Examples
97
-
For examples, see [COUNT (Transact-SQL)](../../t-sql/functions/count-transact-sql.md).
88
+
See [COUNT (Transact-SQL)](../../t-sql/functions/count-transact-sql.md) for examples.
0 commit comments