Back to Practice
#0083

Customers With Recent Orders

MediumSQL20 min15 XP

Problem

Return customer_id and name for customers with at least one order on or after 2026-01-01. Avoid duplicate customers.

Why This Matters

Joins plus filters are the bread and butter of analytics interviews.

Schema

customers(customer_id INTEGER, name TEXT); orders(order_id INTEGER, customer_id INTEGER, order_date TEXT)

Examples

Example 1
InputAsha has a 2026 order, Ben has only 2025 order
OutputAsha only

The date filter defines active.

Constraints

  • Return distinct customers.
  • Sort by customer_id.
  • Use an inner join.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Recent order filter
Inputcustomers and orders
Expectedcustomers with 2026+ orders

Only recent orders qualify.

Hidden Test Categories
duplicate recent ordersno recent ordersmultiple customers