Home> Database> SQL> body text

having usage

藏色散人
Release: 2019-07-29 14:07:27
Original
23587 people have browsed it

having usage

The function of the where clause is to remove rows that do not meet the where conditions before grouping the query results, that is, filtering the data before grouping. The conditions cannot contain aggregation functions. Use where condition to display specific rows.

The function of the having clause is to filter the groups that meet the conditions, that is, filter the data after grouping. The conditions often include aggregation functions. Use the having condition to display specific groups, or multiple groupings can be used. Standard grouping.

The having clause is restricted to columns and aggregate expressions that have been defined in the SELECT statement. Typically, you need to reference aggregate values by repeating the aggregate function expression in the HAVING clause, just as you do in the SELECT statement.

For example:

SELECT A COUNT(B) FROM TABLE GROUP BY A HAVING COUNT(B)>2
Copy after login

Related recommendations: "SQL Tutorial"

The above is the detailed content of having usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!