Some parts in the output code are omitted for clarity reasons.
Description
This function returns the rank of each row within a result set partition, with no gaps in the ranking values. The rank of a specific row is one plus the number of distinct rank values that come before that specific row. (DENSE_RANK in Transact-SQL ).
Sample Source Pattern
Syntax
SQL Server Snowflake SQL
Copy DENSE_RANK ( ) OVER ( [ <partition_by_clause> ] < order_by_clause > )
Snowflake SQL Documentation
Copy DENSE_RANK ( )
-- ** SSC-EWI-0001 - UNRECOGNIZED TOKEN ON LINE 1 COLUMN 15 OF THE SOURCE CODE STARTING AT 'OVER'. EXPECTED 'BATCH' GRAMMAR. **
-- OVER ( [ <partition_by_clause> ] < order_by_clause > )
Examples
SQL Server Snowflake SQL
Code:
Copy SELECT TOP 10 BUSINESSENTITYID, NATIONALIDNUMBER, RANK() OVER (ORDER BY NATIONALIDNUMBER) AS RANK FROM HUMANRESOURCES.EMPLOYEE AS TOTAL
Result:
Copy BUSINESSENTITYID|NATIONALIDNUMBER|DENSE_RANK|
----------------+----------------+----------+
57|10708100 | 1|
54|109272464 | 2|
273|112432117 | 3|
4|112457891 | 4|
139|113393530 | 5|
109|113695504 | 6|
249|121491555 | 7|
132|1300049 | 8|
214|131471224 | 9|
51|132674823 | 10|
Code:
Copy SELECT TOP 10
BUSINESSENTITYID,
NATIONALIDNUMBER,
RANK () OVER ( ORDER BY NATIONALIDNUMBER) AS RANK
FROM
HUMANRESOURCES.EMPLOYEE AS TOTAL;
Result:
Copy BUSINESSENTITYID|NATIONALIDNUMBER|DENSE_RANK|
----------------+----------------+----------+
57|10708100 | 1|
54|109272464 | 2|
273|112432117 | 3|
4|112457891 | 4|
139|113393530 | 5|
109|113695504 | 6|
249|121491555 | 7|
132|1300049 | 8|
214|131471224 | 9|
51|132674823 | 10|
Related EWIs
Last updated 9 months ago