dataengref migrate

Home / Teradata

Teradata QUALIFY in Snowflake, Databricks and BigQuery

QUALIFY started as a Teradata extension, and all three targets support it now. Older Teradata shorthand inside it, such as RANK(score DESC) without OVER, must be rewritten.

Teradata syntax: SELECT ... QUALIFY window_condition · Teradata docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameQUALIFY <predicate>Evaluated after window functions.Snowflake docs
DatabricksSame nameQUALIFY boolean_expressionEvaluated after window functions.Databricks docs
BigQuerySame nameQUALIFY bool_expressionA window function must appear in the QUALIFY clause or the SELECT list.BigQuery docs

Behavior differences to check

Examples

Top 3 products per category

Teradata
SELECT category, product, sales FROM product_sales QUALIFY ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) <= 3;
Snowflake
SELECT category, product, sales FROM product_sales QUALIFY ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) <= 3;
Databricks
SELECT category, product, sales FROM product_sales QUALIFY ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) <= 3;
BigQuery
SELECT category, product, sales FROM product_sales QUALIFY ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) <= 3;

Other Teradata functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.