CommencerCommencer gratuitement

Filtering with HAVING

HAVING works exactly like a WHERE clause but it accepts aggregates as conditions. This helps filter your aggregated queries to find more specific trends.

Here you want to find all the product categories that have an average weight over a certain amount to find the categories that might incur higher shipping costs due to weight.

Cet exercice fait partie du cours

Introduction to BigQuery

Afficher le cours

Instructions

  • Complete the query by finding the average product weight (product_weight_g), grouped by the product category (product_category_name_english) from the ecommerce.ecomm_products table.
  • Use HAVING to find product categories with an average weight over 10,000 grams.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

-- Write a query that finds all product categories and their average weight with an average weight over 10,000 grams

SELECT
	-- Add the product_category_name_english column and the average weight
    ___
FROM ecommerce.ecomm_products
-- Add the GROUP BY statement
___
-- Add the HAVING condition on the average weight aggregate
___
Modifier et exécuter le code