Yesterday, I ran into a query with two result sets. The query took nearly 8 points and it was still being queried.
Check the total data one by one to test the result set. An error is returned:
Message 8115, level 16, status 2, 1st rows
Arithmetic overflow error converting expression to data type Int.
At first glance, it is beyond the type, but the storage below is much smaller than the int data volume. Baidu, it turns out that the data volume requested by count exceeds the total number of int types.
Count_big always returnsBigintData Type value. Count always returnsIntData Type Value
Syntax
|
Count_big({[All | distinct]Expression} | *) |
Parameters
-
All
-
Performs aggregate function operations on all values. All is the default value.
-
Distinct
-
Specifies the number of unique non-null values returned by count_big.
-
Expression
-
Is an expression of any type. Aggregate functions and subqueries are not allowed.
-
*
-
Specify that all rows should be calculated to return the total number of rows in the table. Count_big (*) And cannot be used with distinct. Count (*) Not requiredExpressionParameter, because according to the definition, this function does not use information about any specific column. Count_big (*) Returns the number of rows in the specified table and counts the repeated rows. It counts each row separately. Contains rows that contain null values.
Return type
Bigint
Remarks
Count_big (*) returns the number of items in the group. Including null values and repeated items.
Count_big (allExpression) Is calculated for each row in the group.ExpressionAnd return the number of non-null values.
Count_big (distinctExpression) Is calculated for each row in the group.ExpressionAnd return the number of unique non-null values.