Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

sql - SQL多列排序(SQL multiple column ordering)

I am trying to sort by multiple columns in SQL, and in different directions.

(我试图按SQL中不同方向的多个列进行排序。)

column1 would be sorted descending, and column2 ascending.

(column1将按降序排序,而column2将按升序排序。)

How can I do this?

(我怎样才能做到这一点?)

  ask by Se?or Reginold Francis translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
ORDER BY column1 DESC, column2

每当两行或更多行的column1字段相等时,这将首先按column1 (降序)对所有内容进行排序,然后按column2 (升序,这是默认设置)对所有内容进行排序。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...