ComeçarComece de graça

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.

Este exercício faz parte do curso

Introduction to BigQuery

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

-- 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
___
Editar e executar o código