This question evaluates a candidate's understanding of SQL aggregation and group-level filtering, specifically the roles of WHERE and HAVING when filtering aggregates and how query execution order affects which clauses can reference aggregate expressions.
Filter groups based on an aggregate and explain WHERE vs HAVING. Provide a query that returns merchants with chargeback_rate > 0.5% in the last 30 days using HAVING. Clarify why WHERE cannot reference aggregates, how HAVING works after GROUP BY, dialect differences (e.g., MySQL allowing expressions in HAVING without GROUP BY), and performance considerations.