Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Rank Members by Logging Frequency
00:00
5 left

Rank Members by Logging Frequency

MediumSQL · PostgreSQL

Problem

Write a query using window functions to rank Omada Health members by their total weight-loss logging frequency within their first month.

Use the member enrollment date to define the first month. Include members with no qualifying logs, exclude members without an enrollment date, and count only logs recorded from enrollment through the end of the following one-month period.

Output

  1. One row per eligible member with member_id, member_name, log_count, and frequency_rank
  2. Ties share the same rank
  3. Order by frequency_rank ascending, then member_id ascending

Schema

members
ColumnTypeDescription
member_idPKINTUnique Omada Health member identifier
member_nameVARCHAR(100)Member display name
enrollment_dateDATEDate the member enrolled with Omada Health
weight_logs
ColumnTypeDescription
log_idPKINTUnique weight logging event identifier
member_idINTMember associated with the weight log
logged_atTIMESTAMPTimestamp when the weight was logged
Tablesmembersweight_logs
Interviewer

Your question is Rank Members by Logging Frequency. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.