Marketing wants to reward loyal customers. Using the orders table, return customer_id for every customer who placed orders in at least two consecutive calendar months, ordered by customer_id.
orders
| column | type |
|---|---|
| id | INTEGER |
| customer_id | INTEGER |
| amount | NUMERIC |
| created_at | DATE |
| id | customer_id | amount | created_at |
|---|---|---|---|
| 1 | 1 | 100.00 | 2024-01-10 |
| 2 | 1 | 150.00 | 2024-02-15 |
| 3 | 2 | 200.00 | 2024-01-05 |
| 4 | 2 | 75.00 | 2024-03-20 |
| 5 | 3 | 90.00 | 2024-02-01 |
| 6 | 3 | 120.00 | 2024-03-12 |
| customer_id |
|---|
| 1 |
| 3 |
Customer 1 ordered in January and February (consecutive months) — qualifies. Customer 2 ordered in January and March (one month gap) — does not qualify. Customer 3 ordered in February and March (consecutive) — qualifies.