PostgreSQL , order by , 排序 , 字段 , 表達式 , 位置
在一些Oracle的使用者中,會問到是否支援order by INT這樣的查詢文法。它是什麼意思呢?實際上就是按查詢子句的第幾個表達式進行排序。
<a href="https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm">https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm</a>
按 表達式、列别名、select位置排序。
PostgreSQL也支援這種文法。
PostgreSQL 天然支援 order by [字段、表達式、位置]。
例子
1、按别名排序
2、按SELECT中的位置排序
3、按表達式排序
<a href="https://www.postgresql.org/docs/10/static/sql-select.html">https://www.postgresql.org/docs/10/static/sql-select.html</a>
<a href="https://www.postgresql.org/docs/10/static/sql-expressions.html#sql-syntax-collate-exprs">https://www.postgresql.org/docs/10/static/sql-expressions.html#sql-syntax-collate-exprs</a>