MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to Snowflake SQL

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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
___
___
Edit dan Jalankan Kode