SQL multiple column ordering

后端 未结 5 2211
梦谈多话
梦谈多话 2020-11-22 02:40

I am trying to sort by multiple columns in SQL, and in different directions. column1 would be sorted descending, and column2 ascending.

How

5条回答
  •  旧时难觅i
    2020-11-22 03:20

    ORDER BY column1 DESC, column2
    

    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.

提交回复
热议问题