Get startedGet started for free

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.

This exercise is part of the course

Introduction to BigQuery

View Course

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

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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
___
Edit and Run Code