Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Second-Highest Warehouse Transaction Volume

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

Your question is Second-Highest Warehouse Transaction 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

Find the warehouse with the second-highest total posted transaction volume. Sum quantity by warehouse using only rows where status = 'posted', and return the warehouse name with its total volume. If multiple warehouses tie for second place, return all of them.

Schema

warehouses
ColumnTypeDescription
warehouse_id
warehouse_name
region_code
warehouse_transactions
ColumnTypeDescription
transaction_id
warehouse_id
transaction_date
quantity
status

Representative Rows

warehouses
3Dallas HubSOUTH
1Phoenix DCWEST
5Reno OverflowWEST
warehouse_transactions
10422024-02-0390posted
10112024-02-01120posted
11052024-02-0550posted
Tableswarehouseswarehouse_transactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results