Multiple level ordering

前端 未结 2 768
渐次进展
渐次进展 2021-02-02 06:04

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

相关标签:
2条回答
  • 2021-02-02 06:37

    This query should do the trick:

    SELECT * FROM (SELECT * FROM table ORDER BY rating DESC LIMIT 20) ORDER BY name
    
    0 讨论(0)
  • 2021-02-02 06:40

    You could use e.g. ORDER BY rating DESC, name ASC to sort by rating and then, if the ratings are equal, by name.

    0 讨论(0)
提交回复
热议问题