there is a user ranking table, which needs to be sorted by score and output. If there is a duplicate user, take the highest score of that user
now I write
DB::select("SELECT nickname, id, fraction, FIND_IN_SET( fraction, (
SELECT GROUP_CONCAT( fraction
ORDER BY fraction DESC )
FROM fan_rankings WHERE test_id=$test_id)
) AS rank
FROM fan_rankings
WHERE test_id = $test_id AND user_id = $user->id ORDER BY fraction DESC");
I added a GROUP BY (user_id before ORDER BY), but if there is an error, please tell me what to do
and how to write it in ORM. I feel it"s a bit complicated to write in native
my own version of laravel5.4
Please don"t hesitate to give me your advice