Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top 5 Regions by Volume

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

Your question is Top 5 Regions by Volume. Start with the requirements and the two 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

FedEx Business Intelligence analysts use regional shipment summaries to support network planning and operational reporting. Write a PostgreSQL query to identify the top five regions by total package volume.

Requirements

  1. Join the region reference table to shipment records.
  2. Aggregate package_count for each region, treating regions without shipments as volume 0.
  3. Return the five highest-volume regions, ordering by volume descending and region name ascending as a deterministic tie-breaker.

Schema

fedex_regions
ColumnTypeDescription
region_idPKINTEGERUnique identifier for a FedEx operating region
region_nameVARCHAR(50)Name of the operating region
fedex_shipments
ColumnTypeDescription
shipment_idPKINTEGERUnique shipment record identifier
region_idINTEGERReferenced operating region; NULL indicates an unassigned shipment
package_countINTEGERNumber of packages represented by the shipment record
Tablesfedex_regionsfedex_shipments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results