The Miserable Tripper

View Original

About SQL’s “Having”

Something I SHOULD have been using a long time ago!

this is the SQL Syntax of “Having” (link is to Snowflake Doc)

For me, it can be used instead of a more elaborate “Where”.

Looking forward to using this and seeing how it can be used effectively, consulting the article by geeksforgeeks it below are worth remembering…

we use WHERE prior to GROUP BY and HAVING after GROUP BY.

The Where clause acts as a pre filter where as Having as a post filter.

https://www.geeksforgeeks.org/having-vs-where-clause-in-sql/

See this content in the original post

My old habit would’ve achieved the same result but with a nested query….

See this content in the original post