SQL 多列排序 [英] SQL multiple column ordering

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

问题描述

如何按 SQL 中的多列和不同方向进行排序.column1 将降序排列,column2 升序.

How can I sort by multiple columns in SQL and in different directions. column1 would be sorted descending, and column2 ascending.

推荐答案

ORDER BY column1 DESC, column2

这首先按 column1(降序)排序,然后按 column2(升序,这是默认值),只要 column1 字段两行或多行相等.

This sorts everything by column1 (descending) first, and then by column2 (ascending, which is the default) whenever the column1 fields for two or more rows are equal.

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

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