queryRank function

Rank query.