Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Flag Sellers With High Return Rates
00:00
5 left

Flag Sellers With High Return Rates

MediumSQL · PostgreSQL

Problem

You are given order, return, and seller data. Write a PostgreSQL query that finds sellers with unusually high return rates over the last quarter, where return rate is the number of returned orders divided by total completed orders in that quarter. Return each seller’s ID, seller name, total orders, returned orders, and return rate, and only include sellers whose return rate is above 20%.

Schema

sellers
ColumnTypeDescription
seller_idPKINTPrimary key for each seller
seller_nameVARCHAR(255)Seller display name
orders
ColumnTypeDescription
order_idPKINTPrimary key for each order
seller_idINTSeller who fulfilled the order
order_dateDATEOrder completion date
order_statusVARCHAR(50)Order status such as completed or canceled
returns
ColumnTypeDescription
return_idPKINTPrimary key for each return
order_idINTOrder that was returned
return_dateDATEDate the return was created
Tablessellersordersreturns
Interviewer

Your question is Flag Sellers With High Return Rates. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.