AnalystPath

Members Lifting Heavier Over Time

SQLMediumMid level~15 min

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.

lift_log
member_idexerciseweight_kglogged_on
501Squat802024-03-02
501Squat952024-03-30
501Bench602024-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

Related SQL questions