zlacker

[parent] [thread] 1 comments
1. RaftPe+(OP)[view] [source] 2024-08-24 21:21:58
> 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)

replies(1): >>sgarla+7u1
2. sgarla+7u1[view] [source] 2024-08-25 13:54:17
>>RaftPe+(OP)
The main (only?) task I routinely use HAVING for is finding duplicates.
[go to top]