Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

ranking functions in sql

ROW_NUMBER() -- 1,2,3,4,5 (different rank no. to same value)
RANK() --  1,2,2,4,5 (same rank no. to same value but next rank is skipped)
DENSE_RANK() --  1,2,2,3,4 (same rank no. to same value but no skip in rank no.)

RANKING FUNCTION NAME() OVER([PARTITION BY <COLUMN NAME>] ORDER BY
<COLUMN NAME> [ASC / DESC])
-- PARTITION BY ------> OPTIONAL (ON GROUP OF ROWS).
-- ORDER BY -------> MANADATORY CLAUSE.
 
PREVIOUS NEXT
Tagged: #ranking #functions #sql
ADD COMMENT
Topic
Name
4+8 =