Order by的几种用法
2023-06-30
1. 按列名排序,默认是升序的。
单列升序:select from order by ;
单列降序:select from table_name order by desc;
多列升序:select , from table_name order by , ;
多列降序:select , from order by desc, desc;
多列混合降序:select column_one, column_two from table_name order by column_one desc, column_two desc;
2. 按列的位序排序, 默认是升序
select * from order by 1
3. NULL排序
空值在前:select from order by NULLS FIRST;
空值在后:select from order by NULLS LAST;