Revenue per week
Delivr's first full month of operations was June 2018. At launch, the Marketing team ran an ad campaign on popular food channels on TV, with the number of ads increasing each week through the end of the month. The Head of Marketing asks you to help her assess that campaign's success.
Get the revenue per week for each week in June and check whether there's any consistent growth in revenue.
Note: Don't be surprised if you get a date in May in the result. DATE_TRUNC('week', '2018-06-02')
returns '2018-05-28'
, since '2018-06-02'
is a Saturday and the preceding Monday is on '2018-05-28'
.
This exercise is part of the course
Analyzing Business Data in SQL
Exercise instructions
- Write the expression for revenue.
- Keep only the records of June 2018.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT DATE_TRUNC('week', order_date) :: DATE AS delivr_week,
-- Calculate revenue
___ AS revenue
FROM meals
JOIN orders ON meals.meal_id = orders.meal_id
-- Keep only the records in June 2018
WHERE ___
GROUP BY delivr_week
ORDER BY delivr_week ASC;