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

MAU monitor (II)

Now that you've built the basis for Carol's MAU monitor, write a query that returns a table of months and the deltas of each month's current and previous MAUs.

If the delta is negative, less users were active in the current month than in the previous month, which triggers the monitor to raise a red flag so the Product team can investigate.

Bu egzersiz

Analyzing Business Data in SQL

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

Egzersiz talimatları

  • Fetch the previous month's MAU in the mau_with_lag CTE..
  • Select the month and the delta between its MAU and the previous month's MAU.
  • Order by month in ascending order.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

WITH mau AS (
  SELECT
    DATE_TRUNC('month', order_date) :: DATE AS delivr_month,
    COUNT(DISTINCT user_id) AS mau
  FROM orders
  GROUP BY delivr_month),

  mau_with_lag AS (
  SELECT
    delivr_month,
    mau,
    -- Fetch the previous month's MAU
    COALESCE(
      ___,
    0) AS last_mau
  FROM mau)

SELECT
  -- Calculate each month's delta of MAUs
  ___,
  ___ AS mau_delta
FROM mau_with_lag
-- Order by month in ascending order
ORDER BY ___;
Kodu Düzenle ve Çalıştır