Posted On: Jul 17, 2023

HAQM Redshift now supports the QUALIFY clause in SELECT SQL statements, which allows you to apply filtering conditions to the result of a window function without using a subquery. By filtering the results of window functions, you can focus on the desired data segments and derive insights from your data more efficiently.

HAQM Redshift already supports the HAVING clause, and the QUALIFY clause is particularly useful for analytical queries that involve window functions. It enables you to perform calculations and analysis on specific subsets of data based on defined partitions or windows. You can use both the QUALIFY and HAVING clauses in one query. It also allows you to apply more complex filtering conditions, such as aggregated or computed values, which may not be achievable using regular WHERE clauses alone. 

The QUALIFY clause in SELECT SQL statements is available in all commercial and AWS GovCloud (US) Regions where HAQM Redshift is available. To learn more, visit the HAQM Redshift database developer guide.