On this page
  1. HAVING
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

HAVING

Prev: `GROUP BY` | Up: clauses | Next: `ORDER BY`
Rel: clauses, SQL Query Execution Lifecycle
Ref: PostgreSQL — SQL Commands
Tags: #public #databases #sql #clauses #tier/core


Syntax & Overview

HAVING COUNT(*) >= 3

Filters aggregated groups after GROUP BY.

Notes & Best Practices

Example

SELECT user_id, COUNT(*) AS orders
FROM orders
WHERE created_at >= '2026-01-01'
GROUP BY user_id
HAVING COUNT(*) >= 3;

Linked from

Related notes