Aan de slagGa gratis aan de slag

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'.

Deze oefening maakt deel uit van de cursus

Analyzing Business Data in SQL

Cursus bekijken

Oefeninstructies

  • Write the expression for revenue.
  • Keep only the records of June 2018.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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;
Code bewerken en uitvoeren