Back-To-School Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Multiple metrics for a single object
Metrics for two groups
5. Custom metrics – exercise
Ratios and percentages
Global vs. specific metrics
Summary

Instruction

Perfect! One more exercise before we move on.

Exercise

For each order, determine how many line items (unique products) were discounted and how many weren't. Show three columns:

  • The order ID (order_id).
  • The number of line items that were not discounted (as full_price_product_count).
  • The number of line items that were discounted (as discount_product_count)

Stuck? Here's a hint!

You can use the following to calculate the number of full-price products in each order:

COUNT(CASE
  WHEN discount = 0
    THEN product_id
END)