Challenge: Analyzing Top Products
Scorri per mostrare il menu
Modern Practice
In the video and course examples, you will see the JSON_EXTRACT function. While this function is fully supported and works correctly, it is considered legacy syntax in BigQuery.
For your own future projects, we recommend using the modern standard functions:
JSON_VALUE: extracts scalar values (like strings or numbers) and removes extra quotes automatically;JSON_QUERY: extracts complex JSON objects or arrays.
Write a query that shows sales analysis for our top products using the data in our retail_data_updated table:
- Extract product names from the JSON in the
'products'column; - Count how many times each product appears in transactions;
- Calculate the total revenue generated by each product;
- Group results by product name;
- Sort by the most frequently purchased products.
Your query should return these columns:
'product_name'(extracted from JSON);'purchase_count'(how many times this product appears);'total_revenue'(sum of transaction amounts where this product appears).
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 2. Capitolo 2
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Sezione 2. Capitolo 2