AnalystPath

Next-Day Workout Retention

SQLHardSenior level~15 min

Problem

A fitness app records each workout session a member logs.

Table: workout_log
+-------------+------+
| Column Name | Type |
+-------------+------+
| member_id | int |
| device_id | int |
| log_date | date |
| minutes | int |
+-------------+------+
There may be several rows per member. Each row records one day on which the member logged a workout. A member's signup date is taken to be the earliest log_date they have.

Write a solution to report, for each signup date, how many members signed up on that date and the fraction of those members who logged another workout on the very next day (the day immediately after signup), rounded to 2 decimal places. Return columns signup_date, signups, and next_day_rate in any order.

Tables

Example rows — the live problem includes the full dataset.

workout_log
member_iddevice_idlog_dateminutes
122022-03-0145
122022-03-0230
232022-04-1020

Expected output

Your answer should return 3 rows with the columns signup_date, signups, next_day_rate.

Starter code (SQL)

SELECT *
FROM workout_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