Monthly completed revenue

aggregations

Monthly completed revenue

Stripe SQL Interview Question

A business uses Stripe to take payment for its online orders. Stripe's reporting team wants to show that business how its revenue changed from month to month. Every order was placed in 2024.

Find the total revenue from completed orders in each month. Show the month number (1 for January through 12 for December) as order_month and the total as revenue. Sort the rows by order_month, earliest first.

Asked of

  • Data Analyst
  • BI Analyst
  • Product Analyst
  • Analytics Engineer

ordersTable35 rows

Column NameType
order_idBIGINT
customer_idBIGINT
order_dateDATE
statusVARCHAR
amountDOUBLE

ordersExample Input

order_idcustomer_idorder_datestatusamount
100112024-01-05completed120.5
100222024-01-07completed2400
100312024-01-11completed89.99
100432024-01-15canceled45
100542024-01-18completed610.75
100622024-01-22completed1850.25
100752024-01-29completed3200
100812024-02-02refunded75
100962024-02-06completed55.4
101032024-02-09completed132.6

Example Output

order_monthrevenue
18271.49
2188

Explanation

In January, six completed orders add up to 8,271.49, and the canceled order is not counted. In February, the refunded order is left out, so revenue is 55.40 plus 132.60, which is 188.

The example above is a small slice of the data. Your query runs against the full tables.