Why I am not getting unique ranks for all numbers
There are multiple functions for RANK and all work in different ways. If you want to get the unique rank for all irrespective of the same value, use rank_unique() unction instead of rank function.