Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Analyze Monthly Revenue Trends by Product Category

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

Your question is Analyze Monthly Revenue Trends by Product Category. Start with the requirements and the one table 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

A financial analytics platform needs to analyze revenue trends by product category over the past year. Write a SQL query to calculate the monthly total revenue for each category, along with the cumulative revenue for each category ordered by month.

Requirements

  1. Group revenue by category and transaction_month
  2. Calculate total revenue per category per month
  3. Include cumulative revenue for each category
  4. Order results by category and transaction_month

Schema

transactions
ColumnTypeDescription
idPKINTPrimary key
categoryVARCHARProduct category
transaction_dateDATEDate of transaction
amountDECIMALTransaction amount
Tablestransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results