Row_Number, Rank and Dense_Rank
Syntax: SELECT names , salary ,row_number () OVER (ORDER BY salary DESC) as ROW_NUMBER ,rank () OVER (ORDER BY salary DESC) as RANK ,dense_rank () OVER (ORDER BY salary DESC) as DENSE_RANK FROM salaries Output: Row_number assign different number to them. Rank and Dense_rank both assign same rank to A and B. But interesting thing is what RANK and DENSE_RANK assign to next row? Rank assign 5 to the next row, while dense_rank assign 4. The numbers returned by the DENSE_RANK function do not have gaps and always have consecutive ranks. The RANK function does not always return consecutive integers. The ORDER BY clause determines the sequence in which the rows are assigned their unique ROW_NUMBER within a specified partition. These all can be used ...