20 October 2018        Add to Favorites   Report

An equivalent of "QUALIFY" command in Snowflake

Teradata supports QUALIFY function that offers great flexibility to filter only the rows that pass the ranking or row_number. However, when you are migrating to Snowflake, the qualify function is missing in Snowflake

Teradata Qualify Command:

SELECT c1
FROM t1
WHERE c1='A'
QUALIFY ROW_NUMBER() OVER
(PARTITION by c1 ORDER BY c1) = 1;

Snowflake equivalent for Qualify Command:

SELECT * FROM
( SELECT c1, ROW_NUMBER() OVER (PARTITION by c1 ORDER BY c1) rn FROM t1 WHERE c1='A' ) WHERE rn = 1;

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied