Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Analyze Monthly Revenue Trends by Product Category
00:00
5 left

Analyze Monthly Revenue Trends by Product Category

MediumSQL · PostgreSQL

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
Interviewer

Your question is Analyze Monthly Revenue Trends by Product Category. 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.