Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit c4b592d

Browse files
authored
Update count-transact-sql.md
Text revisions to tighten and optimize the reading flow of the material.
1 parent dcde472 commit c4b592d

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

docs/t-sql/functions/count-transact-sql.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest |
3535
# COUNT (Transact-SQL)
3636
[!INCLUDE[tsql-appliesto-ss2008-all-md](../../includes/tsql-appliesto-ss2008-all-md.md)]
3737

38-
Returns the number of items in a group. COUNT works like the [COUNT_BIG](../../t-sql/functions/count-big-transact-sql.md) function. The only difference between the two functions is their return values. COUNT always returns an **int** data type value. COUNT_BIG always returns a **bigint** data type value.
38+
This function returns the number of items found in a group. `COUNT` operates like the [COUNT_BIG](../../t-sql/functions/count-big-transact-sql.md) function. These functions differ only in the data types of their return values. `COUNT` always returns an **int** data type value. `COUNT_BIG` always returns a **bigint** data type value.
3939

4040
![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
4141

@@ -64,38 +64,38 @@ COUNT ( { expression | * } ) OVER ( [ <partition_by_clause> ] )
6464

6565
## Arguments
6666
**ALL**
67-
Applies the aggregate function to all values. ALL is the default.
67+
Applies the aggregate function to all values. ALL serves as the default.
6868

6969
DISTINCT
70-
Specifies that COUNT returns the number of unique nonnull values.
70+
Specifies that `COUNT` returns the number of unique nonnull values.
7171

7272
*expression*
73-
Is an [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type except **text**, **image**, or **ntext**. Aggregate functions and subqueries are not permitted.
73+
An [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type, except **image**, **ntext**, or **text**. Note that `COUNT` does not support aggregate functions or subqueries in an expression.
7474

7575
\*
76-
Specifies that all rows should be counted to return the total number of rows in a table. COUNT(\*) takes no parameters and cannot be used with DISTINCT. COUNT(\*) does not require an *expression* parameter because, by definition, it does not use information about any particular column. COUNT(*) 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.
76+
Specifies that `COUNT` should count all rows to determine the total table row count to return. `COUNT(*)` takes no parameters and does not support the use of DISTINCT. `COUNT(*)` does not require an *expression* parameter because by definition, it does not use information about any particular column. `COUNT(*)` 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.
7777

7878
OVER **(** [ *partition_by_clause* ] [ *order_by_clause* ] [ *ROW_or_RANGE_clause* ] **)**
79-
*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 &#40;Transact-SQL&#41;](../../t-sql/queries/select-over-clause-transact-sql.md).
80-
79+
The *partition_by_clause* divides the result set produced by the `FROM` clause into partitions to which the `COUNT` 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 &#40;Transact-SQL&#41;](../../t-sql/queries/select-over-clause-transact-sql.md) for more information.
80+
8181
## Return types
8282
**int**
8383

8484
## Remarks
85-
COUNT(*) returns the number of items in a group. This includes NULL values and duplicates.
85+
COUNT(\*) returns the number of items in a group. This includes NULL values and duplicates.
8686

87-
COUNT(ALL *expression*) evaluates *expression* for each row in a group and returns the number of nonnull values.
87+
COUNT(ALL *expression*) evaluates *expression* for each row in a group, and returns the number of nonnull values.
8888

89-
COUNT(DISTINCT *expression*) evaluates *expression* for each row in a group and returns the number of unique, nonnull values.
89+
COUNT(DISTINCT *expression*) evaluates *expression* for each row in a group, and returns the number of unique, nonnull values.
9090

91-
For return values greater than 2^31-1, COUNT produces an error. Use COUNT_BIG instead.
91+
For return values exceeding 2^31-1, `COUNT` returns an error. For these cases, use `COUNT_BIG` instead.
9292

93-
COUNT 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).
93+
`COUNT` 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.
9494

9595
## Examples
9696

9797
### A. Using COUNT and DISTINCT
98-
The following example lists the number of different titles that an employee who works at [!INCLUDE[ssSampleDBCoFull](../../includes/sssampledbcofull-md.md)] can hold.
98+
This example returns the number of different titles that an [!INCLUDE[ssSampleDBCoFull](../../includes/sssampledbcofull-md.md)] employee can hold.
9999

100100
```sql
101101
SELECT COUNT(DISTINCT Title)
@@ -112,8 +112,8 @@ GO
112112
(1 row(s) affected)
113113
```
114114

115-
### B. Using COUNT(*)
116-
The following example finds the total number of employees who work at [!INCLUDE[ssSampleDBCoFull](../../includes/sssampledbcofull-md.md)].
115+
### B. Using COUNT(\*)
116+
This example returns the total number of [!INCLUDE[ssSampleDBCoFull](../../includes/sssampledbcofull-md.md)] employees.
117117

118118
```sql
119119
SELECT COUNT(*)
@@ -130,8 +130,8 @@ GO
130130
(1 row(s) affected)
131131
```
132132

133-
### C. Using COUNT(*) with other aggregates
134-
The following example shows that `COUNT(*)` can be combined with other aggregate functions in the select list. The example uses the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
133+
### C. Using COUNT(\*) with other aggregates
134+
This example shows that `COUNT(*)` works with other aggregate functions in the `SELECT` list. The example uses the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
135135

136136
```sql
137137
SELECT COUNT(*), AVG(Bonus)
@@ -150,7 +150,7 @@ GO
150150
```
151151

152152
### D. Using the OVER clause
153-
The following example uses the MIN, MAX, AVG and COUNT functions with the OVER clause to provide aggregated values for each department in the `HumanResources.Department` table in the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
153+
This example uses the `MIN`, `MAX`, `AVG` and `COUNT` functions with the `OVER` clause, to return aggregated values for each department in the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database `HumanResources.Department` table.
154154

155155
```sql
156156
SELECT DISTINCT Name
@@ -195,7 +195,7 @@ Tool Design 8.62 29.8462 23.505
195195
## Examples: [!INCLUDE[ssSDWfull](../../includes/sssdwfull-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]
196196

197197
### E. Using COUNT and DISTINCT
198-
The following example lists the number of different titles that an employee who works at a specific company can hold.
198+
This example returns the number of different titles that an employee of a specific company can hold.
199199

200200
```sql
201201
USE ssawPDW;
@@ -211,8 +211,8 @@ FROM dbo.DimEmployee;
211211
67
212212
```
213213

214-
### F. Using COUNT(*)
215-
The following example returns the total number of rows in the `dbo.DimEmployee` table.
214+
### F. Using COUNT(\*)
215+
This example returns the total number of rows in the `dbo.DimEmployee` table.
216216

217217
```sql
218218
USE ssawPDW;
@@ -228,8 +228,8 @@ FROM dbo.DimEmployee;
228228
296
229229
```
230230

231-
### G. Using COUNT(*) with other aggregates
232-
The following example combines `COUNT(*)` with other aggregate functions in the SELECT list. The query returns the number of sales representatives with a annual sales quota greater than $500,000 and the average sales quota.
231+
### G. Using COUNT(\*) with other aggregates
232+
This example combines `COUNT(*)` with other aggregate functions in the `SELECT` list. It returns the number of sales representatives with an annual sales quota greater than $500,000, and the average sales quota of those sales representatives.
233233

234234
```sql
235235
USE ssawPDW;
@@ -249,7 +249,7 @@ TotalCount Average Sales Quota
249249
```
250250

251251
### H. Using COUNT with HAVING
252-
The following example uses COUNT with the HAVING clause to return the departments in a company that have more than 15 employees.
252+
This example uses `COUNT` with the `HAVING` clause to return the departments of a company, each of which has more than 15 employees.
253253

254254
```sql
255255
USE ssawPDW;
@@ -271,7 +271,7 @@ Production 179
271271
```
272272

273273
### I. Using COUNT with OVER
274-
The following example uses COUNT with the OVER clause to return the number of products that are contained in each of the specified sales orders.
274+
This example uses `COUNT` with the `OVER` clause, to return the number of products contained in each of the specified sales orders.
275275

276276
```sql
277277
USE ssawPDW;

0 commit comments

Comments
 (0)