How can I implement a workaround for a rank function in MySQL based on multiple columns

join shbcf.ru