Top meals by cost
Alice from Finance wants to know what Delivr's top 5 meals are by overall cost; in other words, Alice wants to know the 5 meals that Delivr has spent the most on for stocking.
You're provided with an aggregate query; you'll need to fill in the blanks to get the output Alice needs.
Note: Recall that in the meals
table, meal_price
is what the user pays Delivr for the meal, while meal_cost
is what Delivr pays its eateries to stock this meal.
Este exercício faz parte do curso
Analyzing Business Data in SQL
Instruções do exercício
- Calculate cost per meal ID.
- Set the
LIMIT
to 5.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
SELECT
-- Calculate cost per meal ID
___,
___ AS cost
FROM meals
JOIN stock ON meals.meal_id = stock.meal_id
GROUP BY meals.meal_id
ORDER BY cost DESC
-- Only the top 5 meal IDs by purchase cost
LIMIT ___;