thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

QUALIFY Clause

A clause in Snowflake, Databricks SQL, BigQuery and Teradata that filters rows on the result of window functions.

Definition

QUALIFY works for window functions the way HAVING works for aggregates. It is evaluated after window functions are computed, which removes the need for a subquery or CTE to filter on ROW_NUMBER or RANK.

Example

SELECT * FROM orders QUALIFY ROW_NUMBER() OVER (PARTITION BY cust ORDER BY ts DESC) = 1;

Exam tip

In SnowPro questions, QUALIFY is the idiomatic way to deduplicate or take Top-N per group.

Related terms