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
SQL Window Functions for Rolling Metrics
00:00
5 left

SQL Window Functions for Rolling Metrics

MediumSQL · PostgreSQL

Problem

How would you use SQL window functions to compute rolling or week-over-week marketplace metrics at Uber Freight?

Use the freight_marketplace_daily table to calculate weekly marketplace performance by market.

Output

  1. One row per market and calendar week between the minimum and maximum event dates.
  2. Return market, week_start, posted_loads, booked_loads, booking_rate, four_week_avg_booking_rate, wow_booking_rate_change, and four_week_gbv.
  3. Include weeks with no activity, order by market, then week_start.

Schema

freight_marketplace_daily
ColumnTypeDescription
event_idPKINTUnique marketplace activity record identifier
marketVARCHAR(80)Uber Freight marketplace market
event_dateDATEDate of marketplace activity
loads_postedINTNumber of loads posted
loads_bookedINTNumber of loads booked
gross_booking_valueNUMERIC(12,2)Gross booking value generated by the activity
Tablesfreight_marketplace_daily
Interviewer

Your question is SQL Window Functions for Rolling Metrics. Start with the requirements and the one table 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.