Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Break Down Revenue by Business Line

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Break Down Revenue by Business Line. Start with the requirements and the two tables on the right.

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.

Problem

Task

You are given Acumen transaction data and a product mapping table. Write a PostgreSQL query that breaks down performance by business line, returning each business line’s total revenue, transaction count, and average revenue per transaction. Any transaction whose product has a null or missing business line should be grouped into an Unmapped bucket.

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
product_idINTProduct sold in the transaction
transaction_dateDATETransaction date
revenueNUMERIC(12,2)Revenue recognized on the transaction
products
ColumnTypeDescription
product_idPKINTProduct identifier
product_nameVARCHAR(100)Product name
business_lineVARCHAR(50)Business line assigned to the product
Tablestransactionsproducts
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results