I have a table with some records with fields like name, rating etc.
I first want to sort based on rating limiting results to 20 and then on this resultset want to furthe
You could use e.g. ORDER BY rating DESC, name ASC to sort by rating and then, if the ratings are equal, by name.
ORDER BY rating DESC, name ASC