Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Optimizing Customer Revenue Analysis | Query Engine Basics
BigQuery Fundamentals

bookChallenge: Optimizing Customer Revenue Analysis

Swipe to show menu

Write a query that efficiently analyzes customer revenue using Materialized Views and Common Table Expressions (CTEs) on the retail_data_updated table:

  1. Create a Materialized View that pre-aggregates total revenue ('total_amount') for each 'customer_id' and 'customer_country'.
  2. Use a CTE to rank customers within each country based on their 'total_revenue'.
  3. Query the Materialized View to return the top 5 customers by revenue per country.
  4. Sort results by 'customer_country'.

Your query should return these columns:

  • 'customer_id' (unique customer identifier);
  • 'customer_country' (customer's country);
  • 'total_revenue' (sum of 'total_amount' for the customer);
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

SectionΒ 2. ChapterΒ 6
some-alt