多级订购 [英] Multiple level ordering

查看:57
本文介绍了多级订购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子,上面有一些记录,其中包含名称,等级等字段.

I have a table with some records with fields like name, rating etc.

我首先要基于将等级限制结果限制为20进行排序,然后要在此结果集上进一步应用基于名称的排序.

I first want to sort based on rating limiting results to 20 and then on this resultset want to further apply sort based on name.

我知道我们需要使用

Select * from table order by rating Desc limit 20

但是在此结果集上如何应用另一级别的排序?如何在一个sqlite语句中结合这两种类型?

but on this resultset how to apply another level of ordering? How can I combine these two sorts in one sqlite statement?

推荐答案

例如,您可以使用ORDER BY rating DESC, name ASC按等级排序,如果等级相等,则按名称排序.

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

这篇关于多级订购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆