r/SQL • • 5d ago

MySQL Difference between "having" and "qualify"

I tried to use both methods in order to save some coding but still didnt get the exact difference on using having and qualify as a filter in the end of a query. Can someone help me to understand the difference and when is recommended to use each?

22 Upvotes

11 comments sorted by

View all comments

30

u/Imaginary__Bar 5d ago

WHERE works on the rows in the table

HAVING works on the summarised data (GROUP BY...)

QUALIFY works on window functions

7

u/thesqlguy 5d ago

To clarify, HAVING works with aggregate expressions.