sql count (select)
时间: 2023-09-04 17:15:06 浏览: 49
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.