News for hackers. Stuff that matters.
Re:SQL: The difference between WHERE and HAVING by tgv on Tuesday December 14, 2021 @08:55AM (#29551483)
I don't think HAVING is strictly needed, but you need to use a sub-query.

   SELECT x ... HAVING y => SELECT * FROM (x ...) t WHERE y
Re:SQL: The difference between WHERE and HAVING by throwawayffffas on Tuesday December 14, 2021 @09:03AM (#29551559)
Yeah, you are correct it's really just syntactic sugar for that. As another comment points out, WHERE and HAVING are just σ in relational algebra.
Re:SQL: The difference between WHERE and HAVING by maweki on Tuesday December 14, 2021 @09:43AM (#29552025)
In that sense, HAVING and WHERE being different is basically a "free" subquery without allowing subqueries.

One inner σ (WHERE) and one outer σ (HAVING).

If subqueries are allowed, then you don't need that.

Re:SQL: The difference between WHERE and HAVING by FedericoRazzoli on Tuesday December 14, 2021 @12:50PM (#29554694)
You are correct, HAVING is essentially syntax sugar. But to be fair, I'm glad it exists.
Re:SQL: The difference between WHERE and HAVING by tgv on Tuesday December 14, 2021 @12:59PM (#29554844)
Sure, and I remember the version of mySQL that didn't have sub-queries. Having HAVING has your back, then.