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.
34
+
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.
35
35
36
36
[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.
59
+
Applies the aggregate function to all values. ALL serves as the default.
60
60
61
61
DISTINCT
62
-
Specifies that COUNT_BIG returns the number of unique nonnull values.
62
+
Specifies that `COUNT_BIG` returns the number of unique nonnull values.
63
63
64
64
*expression*
65
-
Is an [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type. Aggregate functions and subqueries are not permitted.
65
+
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.
66
66
67
67
*\**
68
-
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.
69
-
70
-
ALL
71
-
Applies the aggregate function to all values. ALL is the default.
72
-
73
-
DISTINCT
74
-
Specifies that AVG be performed only on each unique instance of a value, regardless of how many times the value occurs.
75
-
76
-
*expression*
77
-
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.
68
+
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.
78
69
79
70
OVER **(**[*partition_by_clause*][*order_by_clause*]**)**
80
-
*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).
71
+
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.
81
72
82
73
## Return types
83
74
**bigint**
84
75
85
76
## Remarks
86
-
COUNT_BIG(*) returns the number of items in a group. This includes NULL values and duplicates.
77
+
COUNT_BIG(\*) returns the number of items in a group. This includes NULL values and duplicates.
87
78
88
-
COUNT_BIG (ALL *expression*) evaluates *expression* for each row in a group and returns the number of nonnull values.
79
+
COUNT_BIG (ALL *expression*) evaluates *expression* for each row in a group, and returns the number of nonnull values.
89
80
90
-
COUNT_BIG (DISTINCT *expression*) evaluates *expression* for each row in a group and returns the number of unique, nonnull values.
81
+
COUNT_BIG (DISTINCT *expression*) evaluates *expression* for each row in a group, and returns the number of unique, nonnull values.
91
82
92
-
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).
83
+
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.
93
84
94
85
## Examples
95
-
For examples, see [COUNT (Transact-SQL)](../../t-sql/functions/count-transact-sql.md).
86
+
See [COUNT (Transact-SQL)](../../t-sql/functions/count-transact-sql.md) for examples.
Returns a cryptographic random number generated by the Crypto API (CAPI). The output is a hexadecimal number of the specified number of bytes.
29
+
This function returns a cryptographic, randomly-generated number, generated by the Crypto API (CAPI). `CRYPT_GEN_RANDOM` returns a hexadecimal number with a length of a specified number of bytes.
30
30
31
31
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
The lengthof the number being created. Maximum is 8000. *length*is type**int**.
41
+
The length, in bytes, of the number that `CRYPT_GEN_RANDOM` will create. The *length*argument has an **int** data type, and a value range between 1 and 8000. `CRYPT_GEN_RANDOM` returns NULL for an **int** value outside this range.
42
42
43
43
*seed*
44
-
Optional data to use as a random seed. There must be at least *length*bytes of data. *seed*is **varbinary(8000)**.
44
+
An optional hexadecimal number, for use as a random seed value. The length of *seed*must match the value of the *length*argument. The *seed*argument has a **varbinary(8000)** data type.
45
45
46
46
## Returned Types
47
47
**varbinary(8000)**
48
48
49
49
## Permissions
50
-
This function is public and does not require any special permissions.
50
+
This function is public and it does not require any special permissions.
51
51
52
52
## Examples
53
53
54
54
### A. Generating a random number
55
-
The following example generates a random number 50 bytes long.
55
+
This example generates a random number of length 50 bytes:
56
56
57
57
```sql
58
58
SELECT CRYPT_GEN_RANDOM(50) ;
59
59
```
60
60
61
-
The following example generates a random number 4 bytes long using a 4-byte seed.
61
+
This example generates a random number of length 4 bytes, using a 4-byte seed:
Calculates the cumulative distribution of a value in a group of values in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. That is, CUME_DIST computes the relative position of a specified value in a group of values. For a row *r*, assuming ascending ordering, the CUME_DIST of *r* is the number of rows with values lower than or equal to the value of *r*, divided by the number of rows evaluated in the partition or query result set. CUME_DIST is similar to the PERCENT_RANK function.
31
+
For [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], this function calculates the cumulative distribution of a value within a group of values. In other words, `CUME_DIST` calculates the relative position of a specified value in a group of values. Assuming ascending ordering, the `CUME_DIST` of a value in row *r* is defined as the number of rows with values less than or equal to that value in row *r*, divided by the number of rows evaluated in the partition or query result set. `CUME_DIST` is similar to the `PERCENT_RANK` function.
32
32
33
33
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
34
34
@@ -41,19 +41,20 @@ CUME_DIST( )
41
41
```
42
42
43
43
## Arguments
44
-
OVER **(**[*partition_by_clause*]*order_by_clause***)**
45
-
*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. *order_by_clause* is required. The \<rows or range clause> of the OVER syntax cannot be specified in a CUME_DIST function. For more information, see [OVER Clause (Transact-SQL)](../../t-sql/queries/select-over-clause-transact-sql.md).
44
+
OVER **(**[*partition_by_clause*]*order_by_clause*)
45
+
46
+
The *partition_by_clause* divides the FROM clause result set into partitions, to which the function is applied. If the *partition_by_clause* argument is not specified, `CUME_DIST` treats all query result set rows as a single group. The *order_by_clause* determines the logical order in which the operation occurs. `CUME_DIST` requires the *order_by_clause*. `CUME_DIST` will not accept the \<rows or range clause> of the OVER syntax. See [OVER Clause (Transact-SQL)](../../t-sql/queries/select-over-clause-transact-sql.md) for more information.
46
47
47
48
## Return types
48
49
**float(53)**
49
50
50
51
## Remarks
51
-
The range of values returned by CUME_DIST is greater than 0 and less than or equal to 1. Tie values always evaluate to the same cumulative distribution value. NULL values are included by default and are treated as the lowest possible values.
52
+
`CUME_DIST` returns a range of values greater tnan 0 and less than or equal to 1. Tie values always evaluate to the same cumulative distribution value. `CUME_DIST` includes NULL values by default and treats these values as the lowest possible values.
52
53
53
-
CUME_DIST is nondeterministic. For more information, see [Deterministic and Nondeterministic Functions](../../relational-databases/user-defined-functions/deterministic-and-nondeterministic-functions.md).
54
+
`CUME_DIST` is nondeterministic. See [Deterministic and Nondeterministic Functions](../../relational-databases/user-defined-functions/deterministic-and-nondeterministic-functions.md) for more information.
54
55
55
56
## Examples
56
-
The following example uses the CUME_DIST function to compute the salary percentile for each employee within a given department. The value returned by the CUME_DIST function represents the percent of employees that have a salary less than or equal to the current employee in the same department. The PERCENT_RANK function computes the percent rank of the employee's salary within a department. The PARTITION BY clause is specified to partition the rows in the result set by department. The ORDER BY clause in the OVER clause logically orders the rows in each partition. The ORDER BY clause in the SELECT statement determines the display order of the result set.
57
+
This example uses the `CUME_DIST` function to calculate the salary percentile for each employee within a given department. `CUME_DIST` returns a value that represents the percent of employees with a salary less than or equal to the current employee in the same department. The `PERCENT_RANK` function calculates the percent rank of the employee's salary within a department. To partition the result set rows by department, the example specifies the *partition_by_clause* value. The ORDER BY clause of the OVER clause logically orders the rows in each partition. The ORDER BY clause of the SELECT statement determines the display order of the result set.
Returns the ID of the current request within the current session.
29
+
This function returns the ID of the current request within the current session.
30
30
31
31
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
32
32
@@ -40,7 +40,7 @@ CURRENT_REQUEST_ID()
40
40
**smallint**
41
41
42
42
## Remarks
43
-
To find exact information about the current session and current request, use @@SPID and CURRENT_REQUEST_ID(), respectively.
43
+
To find exact information about the current session, use @@SPID. For exact information about the current request, use CURRENT_REQUEST_ID().
0 commit comments