Syntax

SQL Filter Groups with HAVING Syntax

In SQL, filter groups with having: filters groups after aggregation — GROUP BY country HAVING COUNT(*) > 5

Quick Answer

Syntax
GROUP BY country HAVING COUNT(*) > 5
SQLSyntax

Filter Groups with HAVING

Code example
GROUP BY country HAVING COUNT(*) > 5

Filters groups after aggregation.

Learn More

How to filter groups with having in SQL

  1. Open your SQL file or editor.
  2. Copy the example, then replace its sample names and values for your code.

SQL Filter Groups with HAVING Syntax

Use GROUP BY country HAVING COUNT(*) > 5.

Related Syntax References

Frequently asked questions

What is the SQL syntax for filter groups with having?

Use this pattern: GROUP BY country HAVING COUNT(*) > 5

Can I copy this SQL code example?

Yes. Use Copy code and adapt the example to your program.

Is this SQL syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify