sql count (select)
时间: 2023-09-04 20:15:06 浏览: 52
The SQL COUNT function is used to count the number of rows returned by a SELECT statement. Here is the syntax:
```
SELECT COUNT(column_name) FROM table_name WHERE condition;
```
In this syntax, `column_name` is the name of the column that you want to count, `table_name` is the name of the table that you want to count from, and `condition` is an optional clause that specifies a condition for the count.
For example, if you want to count the number of customers in a table called `customers` that have a `city` of "New York", you would use the following SQL statement:
```
SELECT COUNT(*) FROM customers WHERE city = 'New York';
```
This would return the number of rows that match the condition, which is the number of customers in New York.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)