Aan de slagGa gratis aan de slag

NATURAL JOIN

Pissa, the ever-expanding pizza delivery enterprise, has a new challenge for you. They're interested in discovering which type of pizza generates the most revenue.

Here is the pizza schema for reference:

Schema Diagram

Identify the single top-selling pizza category using your knowledge of NATURAL JOIN.

Deze oefening maakt deel uit van de cursus

Introduction to Snowflake SQL

Cursus bekijken

Oefeninstructies

  • Get the category from the appropriate table.
  • NATURAL JOIN the pizza_type table.
  • Group the records by category from the pt (pizza_type) table.
  • Order the details by total_revenue in descending order and limit to a single record, so that only the top revenue-generating pizza is returned.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT
	-- Get the pizza category
    ___,
    SUM(p.price * od.quantity) AS total_revenue
FROM order_details AS od
NATURAL JOIN pizzas AS p
-- NATURAL JOIN the pizza_type table
___ pizza_type AS pt
-- GROUP the records by category
___
-- ORDER by total_revenue and limit the records
___
___
Code bewerken en uitvoeren