SUM(expr)

  • Adds values of expr across rows in each group.
  • Example:
    FROM products
    SHOW SUM(total_sales)
    GROUP BY product_id
    SINCE -7d
    

COUNT(expr)

  • Counts non-null occurrences of expr within each group.
  • Example:
    FROM products
    SHOW COUNT(quantity_purchased)
    GROUP BY product_id
    SINCE -7d
    

COUNT(*)

  • Counts all rows in each group.
  • Example:
    FROM products
    SHOW COUNT(*)
    GROUP BY geo_country
    SINCE this_month
    

AVG(expr)

  • Average of expr per group.
  • Example:
    FROM products
    SHOW AVG(total_sales)
    GROUP BY product_id
    SINCE past_30_days
    

MIN(expr)

  • Minimum value of expr per group.
  • Example:
    FROM products
    SHOW MIN(total_sales)
    GROUP BY product_id
    SINCE past_90_days
    

MAX(expr)

  • Maximum value of expr per group.
  • Example:
    FROM products
    SHOW MAX(total_sales)
    GROUP BY product_id
    SINCE past_90_days
    

COUNT_DISTINCT(expr)

  • Counts distinct non-null values of expr per group.
  • Commonly used for session-based metrics.
  • Example:
    FROM products
    SHOW COUNT_DISTINCT(view_sessions)
    GROUP BY product_id
    SINCE this_month