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

Exercise

CTEs

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.

Additionally, they're thinking about 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 one.
  • 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 order of the columns.