Back to Practice
#0316

Customers With More Than Two Orders

EasySQL15 min10 XP

Problem

Return customer_id and order_count for customers with more than two orders.

Why This Matters

SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.

Schema

orders(order_id INTEGER, customer_id INTEGER)

Examples

Example 1
Inputcustomer 1 has three orders
Outputcustomer 1 only

HAVING filters after COUNT is computed.

Constraints

  • Return only the requested columns.
  • Use deterministic ORDER BY when multiple rows are returned.
  • Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
Inputcustomer 1 has three orders
Expected[[1,3]]

HAVING filters after COUNT is computed.

Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks