Interview Query

Month Over Month

5
Have you seen this question before?

Given a table of transactions and products, write a function to get the month_over_month change in revenue for the year 2019. Make sure to round month_over_month to 2 decimal places.

Example:

Input:

transactions table

Column Type
id INTEGER
user_id INTEGER
created_at DATETIME
product_id INTEGER
quantity INTEGER

products table

Column Type
id INTEGER
name VARCHAR
price FLOAT

Output:

Column Type
month INTEGER
month_over_month FLOAT
Next question: Converted Sessions
MySQL 8.0.17
Loading editor