Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Modeling for New Analytical Use Case
00:00
5 left

Modeling for New Analytical Use Case

MediumSQL · PostgreSQL

Problem

Describe your process for modeling data for a new analytical use case.

Use source_accounts and source_events to produce a reusable account-level analytical result. Include accounts without qualifying events, exclude events outside January 2025 or without a timestamp, and preserve null source attributes.

Output

  1. One row per account, ordered by account_id ascending.
  2. Columns: account_id, account_name, region, event_count, successful_event_count, total_value, and first_event_at.
  3. Counts and total value must be zero when an account has no qualifying events; first_event_at must remain NULL.

Schema

source_accounts
ColumnTypeDescription
account_idPKINTStable source identifier for an account
account_nameVARCHAR(100)Account display name
regionVARCHAR(50)Optional account region
created_atDATEDate the account was created
source_events
ColumnTypeDescription
event_idPKINTUnique source event identifier
account_idINTAccount associated with the event
event_tsTIMESTAMPTimestamp when the event occurred
event_typeVARCHAR(40)Source event classification
outcomeVARCHAR(20)Result of the event
valueNUMERIC(12,2)Optional numeric event value
Tablessource_accountssource_events
Interviewer

Your question is Modeling for New Analytical Use Case. 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.