What is the difference between ROW_NUMBER, RANK and DENSE_RANK?

SQL window functions · Freshers and experienced

Model answer

ROW_NUMBER gives unique sequential numbers even for ties. RANK gives ties the same rank and skips the next numbers (1, 1, 3). DENSE_RANK gives ties the same rank without gaps (1, 1, 2).

Learn this topic

Window Functions: ROW_NUMBER, RANK and Running Totals in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions