1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Snowflake SQL

Connected

Exercise

Common Table Expressions

Pissa, the company you're consulting for, is planning a promotional campaign and needs your expertise.

The campaign aims to spotlight their most popular pizza based on total orders.

They're also considering introducing a value meal featuring their least expensive pizza.

Your task as a consulting data engineer is to identify both these pizzas.

Instructions

100 XP
  • Create a CTE named most_ordered and limit the results to 1.
  • Create another CTE, called cheapest_pizza and filter for the cheapest pizza using a subquery to find the minimum price.
  • Complete the query to select pizza_id and total_qty aliased as metric from most_ordered CTE.
  • Include pizza_id and price aliased as metric from cheapest_pizza CTE. Note, maintain the order of the columns.
Powered by Snowflake