Customers with 3 consecutive buying months

SQL Hard 16 views
Back to Questions

Problem Description

Find customers who placed at least one order in 3 consecutive months (any year). Return customer_id only. Hint: convert to month buckets, then use a window row_number trick.

Input Format

SQL query

Output Format

Result set

Sample Test Case

Input:
Orders(customer_id, order_date)
Output:
Customer list

Constraints

Assume PostgreSQL-style DATE_TRUNC and interval math

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev