Skip to content
Advertisement

RANK() function with over is creating ranks dynamically for every run

I am creating ranks for partitions of my table. Partitions are performed by name column with ordered by its transaction value. While I am generating these partitions and checking count for each of the ranks, I get different number in each rank for every query run I do.

For 1st run I am getting

For 2nd run I am getting

What can be done, If I need to get same number of partitions getting ranked same for each run Edit: Sorry for the blurring of fields This is the output of field “`query to get this column““

Advertisement

Answer

The RANK window function determines the rank of a value in a group of values. Each value is ranked within its partition. Rows with equal values for the ranking criteria receive the same rank. Drill adds the number of tied rows to the tied rank to calculate the next rank and thus the ranks might not be consecutive numbers.

For example, if two rows are ranked 1, the next rank is 3.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement