Marketing wants to identify repeat buyers for a loyalty campaign. Using the customers and orders tables, find every customer who has placed more than one order — return their id, name, and order_count, ordered from most to fewest orders.
customers
| column | type |
|---|---|
| id | INTEGER |
| name | TEXT |
| TEXT |
orders
| column | type |
|---|---|
| id | INTEGER |
| customer_id | INTEGER |
| amount | NUMERIC |
| created_at | DATE |
customers
| id | name | |
|---|---|---|
| 1 | Alice | alice@example.com |
| 2 | Bob | bob@example.com |
| 3 | Carol | carol@example.com |
| 4 | Dave | dave@example.com |
orders
| id | customer_id | amount | created_at |
|---|---|---|---|
| 1 | 1 | 99.99 | 2024-01-10 |
| 2 | 1 | 49.50 | 2024-02-15 |
| 3 | 2 | 200.00 | 2024-03-01 |
| 4 | 1 | 75.00 | 2024-03-20 |
| 5 | 3 | 30.00 | 2024-04-05 |
| 6 | 3 | 120.00 | 2024-04-18 |
| id | name | order_count |
|---|---|---|
| 1 | Alice | 3 |
| 3 | Carol | 2 |
Alice placed 3 orders and Carol placed 2 — both qualify. Bob placed 1 order (excluded). Dave placed 0 orders (excluded by the inner join).