Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL and Data Manipulation
00:00
5 left

SQL and Data Manipulation

MediumSQL · PostgreSQL

Problem

Tell me about your experience with SQL and data manipulation.

Demonstrate your answer with a query over the provided customer and order data. Return active customers who placed at least two completed orders during 2025, including their order totals and spending classification.

Output

  1. One row per qualifying active customer with customer_id, customer_name, completed_order_count, total_completed_amount, latest_completed_order_date, and spending_tier.
  2. Exclude cancelled orders, orders outside 2025, inactive customers, and customers with fewer than two qualifying orders.
  3. Sort by total_completed_amount descending, then customer_id ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer display name
is_activeBOOLEANWhether the customer account is active
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
customer_idINTCustomer who placed the order
order_dateDATEDate the order was placed
statusVARCHAR(20)Order processing status
amountDECIMAL(10,2)Order amount
Tablescustomersorders
Interviewer

Your question is SQL and Data Manipulation. Start with the requirements and the two 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.