Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.