thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

RANK and DENSE_RANK

Ranking window functions: RANK gives tied rows the same rank and leaves gaps; DENSE_RANK gives ties the same rank without gaps.

Definition

For values 100, 90, 90, 80, RANK returns 1, 2, 2, 4 while DENSE_RANK returns 1, 2, 2, 3 and ROW_NUMBER returns 1, 2, 3, 4. Choose based on how ties should be treated in Top-N results.

Example

DENSE_RANK() OVER (ORDER BY Score DESC)

Exam tip

A frequent question: which function returns 1, 2, 2, 3? The answer is DENSE_RANK.

Related terms