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

Connected

Exercise

Filtering data with CTEs

One of the most effective ways to use a CTE is to filter your data in the CTE before using it later in the query. This reduces the overall cost of the query by bringing less data into the final query. This query will help us find the order status of orders with items that have a price over $150.

Instructions

100 XP
  • Create a new CTE orders for orders with a price over $150, un-nesting order_items to find the price column.
  • Join the results of the CTE to the ecomm_order_details dataset to find the number of order_status and aggregate them by COUNTing the orders in each status.