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

Costs

The C-level execs next tell Eve that they want a report on the total costs by eatery in the last two months.

First, write a query to get the total costs by eatery in November and December 2018, then pivot by month.

Note: Recall from Chapter 1 that total cost is the sum of each meal's cost times its stocking quantity.

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
  -- Select eatery and calculate total cost
  ___,
  DATE_TRUNC('month', stocking_date) :: DATE AS delivr_month,
  ___ :: FLOAT AS cost
FROM meals
JOIN stock ON meals.meal_id = stock.meal_id
-- Keep only the records after October 2018
WHERE ___
GROUP BY eatery, delivr_month
ORDER BY eatery, delivr_month;
Kodu Düzenle ve Çalıştır