having count
时间: 2023-09-14 07:14:04 浏览: 63
word counting
HAVING COUNT is a clause used in SQL to filter the results of a query based on the number of occurrences of a particular value in a column. It is used in conjunction with the GROUP BY clause and is similar to the WHERE clause, but it applies to the aggregated results of a query rather than the individual rows.
For example, suppose we have a table named "students" with columns for "name" and "grade". We can use the HAVING COUNT clause to find the names of students who have more than one grade:
```
SELECT name
FROM students
GROUP BY name
HAVING COUNT(grade) > 1;
```
This query groups the rows by name, counts the number of grades for each name, and filters out any names that have only one grade. The result is a list of names with more than one grade.
阅读全文