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
Joining Tables With Sales Filters
00:00
5 left

Joining Tables With Sales Filters

MediumSQL · PostgreSQL

Problem

HARMAN's Business Analytics team wants a quarterly view of qualifying North American sales across JBL, Harman Kardon, and related product lines. Write a PostgreSQL query that joins orders, order items, and products to identify products meeting the specified sales criteria.

Requirements

  1. Include only orders from North America with status Completed between 2025-01-01 and 2025-03-31.
  2. Include only products in the Audio category.
  3. Calculate total units, distinct order count, and net revenue after discounts, treating a missing discount as 0%.
  4. Keep products with net revenue of at least 250, label each result using CASE, and sort by net revenue descending.

Schema

sales_orders
ColumnTypeDescription
order_idPKINTUnique sales order identifier
order_dateDATEDate the order was placed
regionVARCHAR(50)Geographic sales region
statusVARCHAR(20)Order processing status
order_items
ColumnTypeDescription
item_idPKINTUnique order item identifier
order_idINTReferences sales_orders.order_id
product_idINTReferences products.product_id
quantityINTNumber of units sold
unit_priceNUMERIC(10,2)Price per unit before discount
discount_percentNUMERIC(5,2)Discount percentage applied to the item
products
ColumnTypeDescription
product_idPKINTUnique HARMAN product identifier
product_nameVARCHAR(150)HARMAN product name
categoryVARCHAR(50)Product category
Tablessales_ordersorder_itemsproducts
Interviewer

Your question is Joining Tables With Sales Filters. 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.