Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Weekly Operational Metrics

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL for Weekly Operational Metrics. Start with the requirements and the three tables on the right.

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.

Problem

eBay Operations needs a weekly view of order fulfillment performance across its marketplace operations. Write a PostgreSQL query that combines orders, shipment records, and eBay customer support tickets without double-counting orders that have multiple tickets.

Requirements

  1. Exclude cancelled orders and orders outside January 6 through January 26, 2025.
  2. Group results by the Monday week containing each order date.
  3. Return total orders, gross order value, shipped orders, support ticket count, and the percentage of delivered orders delivered on or before the promised date.
  4. Preserve orders without shipment or support records, and return weeks in chronological order.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique eBay order identifier
buyer_idVARCHAR(20)eBay buyer identifier
order_dateDATEDate the order was placed
promised_dateDATEPromised delivery date
order_amountNUMERIC(10,2)Order value in dollars
order_statusVARCHAR(20)Order lifecycle status
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
order_idINTOrder associated with the shipment
shipped_dateDATEDate the shipment left the fulfillment facility
delivered_dateDATEDate delivered to the buyer
shipment_statusVARCHAR(20)Shipment status
carrierVARCHAR(30)Shipping carrier
support_tickets
ColumnTypeDescription
ticket_idPKINTUnique support ticket identifier
order_idINTOrder referenced by the ticket
created_atTIMESTAMPTicket creation timestamp
resolution_statusVARCHAR(20)Ticket resolution status
issue_typeVARCHAR(30)Customer-reported issue category
Tablesordersshipmentssupport_tickets
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results