oracle order by 排序


Syntax

ORDER BY { column-Name | ColumnPosition | Expression }
    [ ASC | DESC ]
    [ NULLS FIRST | NULLS LAST ]
    [ , column-Name | ColumnPosition | Expression 
    [ ASC | DESC ]
    [ NULLS FIRST | NULLS LAST ]
    ] * 

知識點

  • order by 后面可以接列號(數字)、列名、別名、表達式、函數、分組函數
  • order by 對空值的處理,DESC空值在前,ASC空值在后;
  • order by子句中可以不含select中的列;
  • 當使用select distinctgroup by時,order by 不能使用select之外的列;
  • order by 只能放最后,不能放集合操作的中間;
  • 集合操作后,不接order by時按第一列進行升序排序(union all除外);
  • 集合操作后的列名為第一個select的內容,order by 只能選第一個select中的內容進行操作
select job, avg(sal) "Average Salary" 
    from emp 
    group by job 
    order by "Average Salary" DESC;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM