Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Running Total of Daily Signups

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Running Total of Daily Signups. Start with the requirements and the three tables on the right.

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.

Problem

DeFiner wants a reliable daily signup trend for its analytics dashboard. Write a PostgreSQL query that reports daily signups during February 1 through February 10, 2025, including days with no qualifying signups.

Requirements

  1. Count distinct users whose signup event occurred on each calendar day.
  2. Exclude test users, deleted users, users without a recognized acquisition channel, duplicate signup events, and events outside the requested date range.
  3. Calculate the previous day's signup count with LAG.
  4. Calculate the cumulative signup total with a windowed SUM ordered by date.
  5. Return one row per calendar day in ascending date order.

Schema

users
ColumnTypeDescription
user_idPKINTUnique DeFiner user identifier
created_atTIMESTAMPAccount creation timestamp
channel_idINTAcquisition channel identifier
is_testBOOLEANWhether the account is a test account
deleted_atTIMESTAMPAccount deletion timestamp
signup_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser associated with the event
event_typeVARCHAR(30)Tracked event name
occurred_atTIMESTAMPTimestamp when the event occurred
acquisition_channels
ColumnTypeDescription
channel_idPKINTUnique acquisition channel identifier
channel_nameVARCHAR(100)Human-readable acquisition channel
is_activeBOOLEANWhether the channel is currently active
Tablesuserssignup_eventsacquisition_channels
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results