Part one of sql for mcRank