Get startedGet started for free

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.

This exercise is part of the course

Analyzing Business Data in SQL

View Course

Exercise instructions

  • Calculate cost per meal ID.
  • Set the LIMIT to 5.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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 ___;
Edit and Run Code