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
Window Functions for Throughput Trends
00:00
5 left

Window Functions for Throughput Trends

HardSQL · PostgreSQL

Problem

MSD's research operations team needs a monthly view of completed experimental throughput for active programs. Write a PostgreSQL query that aggregates throughput by experiment date, then calculates cumulative and short-term throughput trends within each calendar month.

Requirements

  1. Join throughput_events to experiments and include only active experiments, completed runs, and nonnegative or NULL throughput values from January and February 2025.
  2. Aggregate throughput by event date and month, treating NULL throughput as zero.
  3. Use window functions partitioned by month to calculate a running total and a three-reported-day moving average, ordered chronologically.
  4. Return one row per reported date, ordered by month and event date.

Schema

experiments
ColumnTypeDescription
experiment_idPKINTUnique experiment identifier
experiment_nameVARCHAR(100)Name of the experiment
therapeutic_areaVARCHAR(80)Therapeutic research area
statusVARCHAR(20)Current experiment program status
throughput_events
ColumnTypeDescription
event_idPKINTUnique throughput event identifier
experiment_idINTExperiment associated with the event
event_dateDATEDate throughput was recorded
throughput_samplesINTNumber of processed samples
run_statusVARCHAR(20)Execution status of the run
Tablesexperimentsthroughput_events
Interviewer

Your question is Window Functions for Throughput Trends. 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.