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 for Weekly Regional Performance
00:00
5 left

SQL for Weekly Regional Performance

MediumSQL · PostgreSQL

Problem

Amazon Kuiper Commercial Services needs a weekly operational view by reporting region. Write a PostgreSQL query for the weeks beginning January 6, January 13, and January 20, 2025.

Requirements

  1. Include every reporting region for every requested week, including weeks with no completed operations.
  2. Count total handled volume using volume_units from completed operations joined to an active service channel.
  3. Calculate average handling time in hours from opened_at to completed_at, rounded to two decimals.
  4. Use LAG to calculate week-over-week volume change as a percentage. Return NULL when the prior week has zero or no volume.
  5. Exclude non-reporting regions, incomplete operations, inactive channels, operations outside the three-week range, and operations with no matching region.
  6. Sort by region name and week start.

Schema

regions
ColumnTypeDescription
region_idPKINTEGERUnique operational region identifier
region_nameVARCHAR(80)Kuiper Commercial Services region name
is_reporting_regionBOOLEANWhether the region is included in reporting
service_channels
ColumnTypeDescription
channel_idPKINTEGERUnique service channel identifier
channel_nameVARCHAR(80)Operational intake channel name
is_activeBOOLEANWhether the channel is active
operational_cases
ColumnTypeDescription
operation_idPKBIGINTUnique operation identifier
region_idINTEGERRegion assigned to the operation
channel_idINTEGERService channel used by the operation
statusVARCHAR(20)Current operation status
volume_unitsINTEGERNumber of units handled
opened_atTIMESTAMPOperation start timestamp
completed_atTIMESTAMPOperation completion timestamp
Tablesregionsservice_channelsoperational_cases
Interviewer

Your question is SQL for Weekly Regional Performance. Start with the requirements and the three 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.