BaşlayınÜcretsiz Başlayın

Order growth rate

Bob needs one more chart to wrap up his pitch deck. He's covered Delivr's gain of new users, its growing MAUs, and its high retention rates. Something is missing, though. Throughout the pitch deck, there's not a single mention of the best indicator of user activity: the users' orders! The more orders users make, the more active they are on Delivr, and the more money Delivr generates.

Send Bob a table of MoM order growth rates.

(Recap: MoM means month-on-month.)

Bu egzersiz

Analyzing Business Data in SQL

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Count the unique orders per month.
  • Fetch each month's previous and current orders.
  • Return a table of MoM order growth rates.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

WITH orders AS (
  SELECT
    DATE_TRUNC('month', order_date) :: DATE AS delivr_month,
    --  Count the unique order IDs
    ___ AS orders
  FROM orders
  GROUP BY delivr_month),

  orders_with_lag AS (
  SELECT
    delivr_month,
    -- Fetch each month's current and previous orders
    ___,
    COALESCE(
      ___,
    1) AS last_orders
  FROM orders)

SELECT
  delivr_month,
  -- Calculate the MoM order growth rate
  ROUND(
    ___,
  2) AS growth
FROM orders_with_lag
ORDER BY delivr_month ASC;
Kodu Düzenle ve Çalıştır