Members Lifting Heavier Over Time
Problem
A gym records every logged set in `lift_log`, one row per member, exercise and date. Find each (member, exercise) pairing where the member logged the same exercise on **at least two different dates** and the weight on their **latest** date is strictly greater than the weight on their **first** date. Compare only the earliest and the most recent entries — what happened in between does not matter. Return `member_id`, `exercise`, the earliest weight as `first_weight`, and the most recent weight as `latest_weight`, ordered by `member_id` then `exercise`.
Tables
Example rows — the live problem includes the full dataset.
| member_id | exercise | weight_kg | logged_on |
|---|---|---|---|
| 501 | Squat | 80 | 2024-03-02 |
| 501 | Squat | 95 | 2024-03-30 |
| 501 | Bench | 60 | 2024-03-02 |
Expected output
Your answer should return 3 rows with the columns member_id, exercise, first_weight, latest_weight.
Starter code (SQL)
SELECT *
FROM lift_log;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