It is recommended to use a temporary table to sort again and again. Each time the sorting results are placed in the temporary table to see if they are correct, and then the next sorting is performed.
Finally, optimize all sorted SQL statements into one.
PS: SQL should be posted in code form as much as possible for the respondent to modify
You can left join the main table to a table with only the first three records, similar to:
SELECT a.*,
b.count AS new_count
FROM test a
LEFT JOIN
( SELECT * FROM test ORDER BY count DESC LIMIT 0, 3 ) b
ON a.id=b.id
ORDER BY new_count DESC,date DESC;
It is recommended to use a temporary table to sort again and again. Each time the sorting results are placed in the temporary table to see if they are correct, and then the next sorting is performed.
Finally, optimize all sorted SQL statements into one.
You can left join the main table to a table with only the first three records, similar to: