Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Analyzing Top Products | Query Engine Basics
BigQuery Fundamentals

bookChallenge: Analyzing Top Products

Sveip for å vise menyen

Note
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:

  1. Extract product names from the JSON in the 'products' column;
  2. Count how many times each product appears in transactions;
  3. Calculate the total revenue generated by each product;
  4. Group results by product name;
  5. 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).
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Seksjon 2. Kapittel 2
some-alt