change solution_by_rank SQL to be intuitive