QUALIFY
clause filters the results of window functions.HAVING
clause filters the results of aggregate functions applied based on the GROUP BY
clause.QUALIFY
clause or the SELECT
list.QUALIFY
clause is typically completed in this order:
FROM
WHERE
GROUP BY
and aggregationHAVING
(filters the results of aggregation)WINDOW
QUALIFY
(filters the results of window functions)DISTINCT
ORDER BY
LIMIT
employee
with the following data:
emp_name | job_title | city | salary |
---|---|---|---|
Rohit | Software Engineer | Delhi | 500000 |
Megha | Data Scientist | Bangalore | 800000 |
Anjali | HR Manager | Bangalore | 400000 |
emp_name | job_title | city | salary |
---|---|---|---|
Rohit | Software Engineer | Delhi | 500000 |
Megha | Data Scientist | Bangalore | 800000 |
Anjali | HR Manager | Bangalore | 400000 |
QUALIFY
clause:
emp_name | job_title | city | salary |
---|---|---|---|
Rohit | Software Engineer | Delhi | 500000 |
Megha | Data Scientist | Bangalore | 800000 |
Anjali | HR Manager | Bangalore | 400000 |
QUALFIY
clause to get the same result.
Window function in SELECT column list
Window function in the QUALIFY clause but using WINDOW clause
Window function in the SELECT clause but using WINDOW clause
QUALIFY
is not part of the ANSI SQL standard. So it is not supported in all databases.