Ranks the current row within its partition with gaps. In other words, if the value of any row it encounters is equal to the value of a previous row then it will receive the same rank as that previous row.
The rank of the next row is then equal to the rank of the previous row plus a gap equal to the number of times the previous rank was given.The dense_rank function provides the same behaviour but without gaps in ranking.Syntax
rank () OVER ([[PARTITION BY grouping_column] [ORDER BY sorting_column] [ROWS or RANGE expression_to_bound_rows_withing_the_group]] | [window_name])FROM table_nameWINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column])