Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Business Question From CSV
00:00
5 left

Business Question From CSV

HardSQL · PostgreSQL

Problem

The interviewer gives you a CSV and asks you to answer a business question using whatever tools you want; how do you approach it from start to finish?

For grading, assume the CSV has been loaded into csv_sales and customer reference data is available in customer_segments. Return completed, non-null sales from Q1 2025, grouped by customer segment, with unknown customers labeled Unclassified. Include only segments with at least two qualifying sales.

Output

  1. One row per qualifying segment with segment, completed_orders, net_sales, and avg_order_value
  2. Net sales equal amount minus discount, treating a missing discount as zero
  3. Order by net_sales descending, then segment ascending

Schema

csv_sales
ColumnTypeDescription
order_idPKINTUnique sales record identifier
customer_idINTCustomer identifier from the CSV
order_dateDATEDate of the sales record
amountDECIMAL(12,2)Gross sales amount
discountDECIMAL(12,2)Discount applied to the sale
statusVARCHAR(20)Sales record status
customer_segments
ColumnTypeDescription
customer_idPKINTUnique customer identifier
segmentVARCHAR(40)Customer segment label
Tablescsv_salescustomer_segments
Interviewer

Your question is Business Question From CSV. 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.