Keep the Earliest Newsletter Signup
Problem
A newsletter tool stores every signup. The same address can appear more than once if someone submitted the form repeatedly.
Table: `signups`
| Column | Type |
|-------------|---------|
| signup_id | int |
| address | varchar |
`signup_id` is the primary key and is assigned in increasing order, so a smaller id means an earlier signup. Addresses are stored in lowercase.
Write a query that returns the de-duplicated list: for each distinct `address`, keep only the row with the **smallest** `signup_id`. Return columns `signup_id` and `address`, ordered by `signup_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
| signup_id | address |
|---|---|
| 1 | maya@list.io |
| 2 | omar@list.io |
| 3 | maya@list.io |
Expected output
Your answer should return 2 rows with the columns signup_id, address.
Starter code (SQL)
SELECT *
FROM signups;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock