WHERE vs HAVING

Why is it that you need to place columns you create yourself (for example “select 1 as number”) after HAVING and not WHERE in MySQL? WHERE is applied before GROUP BY, HAVING is applied after (and can filter on aggregates). In general, you can reference aliases in neither of these clauses, but MySQL allows referencing … Read more