Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Sales and Transactions Per Customer
00:00
5 left

Sales and Transactions Per Customer

EasySQL · PostgreSQL

Problem

A sales analytics team needs a report of customer activity during a fixed 30-day reporting period. Write a SQL query to calculate each customer's total sales volume and transaction count for transactions from August 16, 2026 through September 15, 2026, inclusive.

Output

  1. One row per customer with at least one transaction in the reporting period.
  2. Return customer_id, total_sales_volume, and transaction_count.
  3. Include transactions whose amount is NULL in the transaction count, but treat NULL amounts as contributing zero to total sales volume.
  4. Sort by customer_id in ascending order.

Schema

customer_transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
customer_idINTIdentifier of the customer who made the transaction
transaction_atTIMESTAMPTimestamp when the transaction occurred
amountNUMERIC(12,2)Sales amount for the transaction
Tablescustomer_transactions
Interviewer

Your question is Sales and Transactions Per Customer. Start with the requirements and the one table 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.