HAVING Filtering Clause

Function

This statement is used to filter the query results using the HAVING clause.

Syntax

1
2
3
4
SELECT [ALL | DISTINCT] attr_expr_list FROM table_reference
  [WHERE where_condition]
  [GROUP BY col_name_list]
  HAVING having_condition;

Keyword

Precautions

Example

Group the student table according to the name field and filter the records in which the maximum score is higher than 95 based on groups.

1
2
3
SELECT name, max(score) FROM student
  GROUP BY name
  HAVING max(score) >95;