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
Rank Merchants by Daily Sales
00:00
5 left

Rank Merchants by Daily Sales

MediumSQL · PostgreSQL

Problem

Write a query using window functions to rank merchants based on their daily sales volume within each product category at Alibaba Group.

Use the provided merchant, category, and sales data. Calculate total units sold for each merchant, category, and date. Ties should receive the same rank.

Output

  1. One row per merchant, product category, and sales date with valid merchant and category references.
  2. Columns: category_name, sales_date, merchant_name, daily_sales_volume, and merchant_rank.
  3. Order by sales_date, category_name, merchant_rank, then merchant_name.

Schema

merchants
ColumnTypeDescription
merchant_idPKINTUnique merchant identifier
merchant_nameVARCHAR(100)Merchant display name
categories
ColumnTypeDescription
category_idPKINTUnique product category identifier
category_nameVARCHAR(100)Product category name
sales
ColumnTypeDescription
sale_idPKINTUnique sales record identifier
merchant_idINTMerchant associated with the sale
category_idINTProduct category associated with the sale
sales_dateDATEDate on which the sale occurred
units_soldINTNumber of units sold in the record
Tablessalesmerchantscategories
Interviewer

Your question is Rank Merchants by Daily Sales. 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.