Skip to main content
SQL โ€ข LESSON 91

JOIN with HAVING

How can we find customers who placed more than five orders?

Advancedโฑ 3 Minutesโญ 1040 XP
๐Ÿค” THE QUESTION

How can we find customers who placed more than five orders?

๐Ÿ’ก WHAT IS IT?

HAVING filters aggregated joined rows, identifying accounts that meet high-frequency engagement thresholds.

๐ŸŽฏ WHAT IS IT USED FOR?

VIP customer identification, loyalty reward tier segmentation, frequent buyer analytics.

๐Ÿ’ป EXAMPLE
SELECT c.customer_name, COUNT(o.order_id) AS order_count
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_name
HAVING COUNT(o.order_id) > 5;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for JOIN with HAVING.

  • โœ“ JOIN + HAVING
  • โœ“ VIP segmentation
  • โœ“ Order frequency thresholds
  • โœ“ Customer loyalty analysis