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

Using CTEs

Alice wants to know how much Delivr spent per month on average during its early months (before September 2018). You'll need to write two queries to solve this problem:

  • A query to calculate cost per month, wrapped in a CTE,
  • A query that averages monthly cost before September 2018 by referencing the CTE.

Bu egzersiz, kursun bir parçasıdır

Analyzing Business Data in SQL

Kursa Göz Atın

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

SELECT
  -- Calculate cost
  DATE_TRUNC('month', stocking_date)::DATE AS delivr_month,
  ___ AS cost
FROM meals
JOIN stock ON meals.meal_id = stock.meal_id
GROUP BY delivr_month
ORDER BY delivr_month ASC;
Kodu Düzenle ve Çalıştır