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

Connected

Exercise

Optimizing using CTEs

CTEs also help you optimize queries by handling computations like aggregations before working with the data in the main query.

For example, you want to find the highest number of payments by order item count. This exercise will show you how to do that efficiently with a CTE.

Instructions

100 XP
  • Add the correct aggregate functions in the subquery and the main query.
  • Use ARRAY_LENGTH to find the number of items in each order using the order_items column twice in the main query.