News for hackers. Stuff that matters.
Re:Pipe Syntax in SQL by RaftPeople on Saturday August 24, 2024 @05:21PM (#41341620)
> HAVING is different from WHERE because it filters after the aggregation, without requiring a separate query with an extra SELECT.

Personally I rarely use HAVING and instead use WHERE with subqueries for the following reasons:

1-I don't like repeating/duplicating a bunch of complex calcs, easier to just do WHERE in outer query on result

2-I typically have outer queries anyway for multiple reasons: break logic into reasonable chunks for humans, also for join+performance reasons (to give the optimizer a better chance at not getting confused)

Re:Pipe Syntax in SQL by sgarland on Sunday August 25, 2024 @09:54AM (#41347331)
The main (only?) task I routinely use HAVING for is finding duplicates.