Calculating monthly sales growth in SQL

Question

Given the table below, called 'sales', can you write a SQL query to show the monthly sales growth by channel? To calculate the monthly sales growth, you can apply the following logic:

sales growth = (current month's sales - prior month's sales) / prior month's sales

order_id channel date month sales_total
1 online 2018-09-01 09 100
2 online 2018-09-03 09 125
3 in_store 2018-10-11 10 200
4 in_store 2018-08-21 08 80
5 online 2018-08-13 08 200

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now