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
Core SQL Query Writing
00:00
5 left

Core SQL Query Writing

MediumSQL · PostgreSQL

Problem

TE Connectivity analysts need a quarterly view of customers purchasing AMP connector products. Write a PostgreSQL query that identifies customers meeting both order-count and sales-value thresholds.

Requirements

  1. Join customers, orders, and order_items.
  2. Include only completed orders placed from January 1 through March 31, 2025, with product_family = 'AMP Connector'.
  3. Return each customer’s completed order count and total connector sales, calculated as quantity * unit_price.
  4. Use HAVING to keep customers with at least two qualifying orders and at least $1,000 in sales. Sort by sales descending, then customer name.

Schema

customers
ColumnTypeDescription
customer_idPKINTCustomer identifier
customer_nameVARCHAR(100)Customer name
regionVARCHAR(50)Sales region
orders
ColumnTypeDescription
order_idPKINTOrder identifier
customer_idINTRelated customer identifier
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Order lifecycle status
order_items
ColumnTypeDescription
order_item_idPKINTLine-item identifier
order_idINTRelated order identifier
product_familyVARCHAR(80)TE Connectivity product family
product_nameVARCHAR(120)Product description
quantityINTUnits ordered
unit_priceDECIMAL(10,2)Price per unit
Tablescustomersordersorder_items
Interviewer

Your question is Core SQL Query Writing. 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.