Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Case Study #2 - Pizza Runner/C. Ingredient Optimisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
## Solution - C. Ingredient Optimisation

### 1. What are the standard ingredients for each pizza?
```sql
WITH recipe AS (
SELECT
pizza_id,
UNNEST(STRING_TO_ARRAY(toppings, ', ')::INT[]) AS toppings
FROM pizza_runner.pizza_recipes
)

SELECT
pizza_name, STRING_AGG(topping_name, ', ')
FROM recipe AS r
INNER JOIN pizza_runner.pizza_toppings AS t
ON t.topping_id = r.toppings
INNER JOIN pizza_runner.pizza_names AS n
ON r.pizza_id = n.pizza_id
GROUP BY pizza_name
```

### 2. What was the most commonly added extra?

Expand Down