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
Daily Load SQL for Aggregate Table
00:00
5 left

Daily Load SQL for Aggregate Table

MediumSQL · PostgreSQL

Problem

Write the SELECT portion of a daily load job into an aggregate table, combining the new daily data with the prior snapshot of the aggregate table (full outer join).

Asked in the ETL 1 stage. The query should produce the next daily snapshot from the source events and the previous aggregate snapshot.

Output

  1. One row per account present in either input for the load date.
  2. Columns: account_id, snapshot_date, total_events, and total_revenue.
  3. Add new event totals to prior totals, treat missing numeric values as zero, use 2025-02-15 as the output date, and order by account_id ascending.

Schema

daily_account_events
ColumnTypeDescription
event_idPKINTUnique event identifier
account_idINTAccount associated with the event
event_dateDATEDate on which the event occurred
event_countINTNumber of events represented by the row
revenueNUMERIC(12,2)Revenue attributed to the event row
account_aggregate_snapshot
ColumnTypeDescription
account_idPKINTAccount represented in the snapshot
snapshot_datePKDATEDate of the aggregate snapshot
total_eventsINTCumulative event total through the snapshot date
total_revenueNUMERIC(12,2)Cumulative revenue through the snapshot date
Tablesdaily_account_eventsaccount_aggregate_snapshot
Interviewer

Your question is Daily Load SQL for Aggregate Table. 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.