如果要對計算列排序,可以為計算列指定別名,然後按別名排序。
創建測試用表:
CREATE OR REPLACE VIEW v AS SELECT 3 AS a, 4 AS b FROM DUAL UNION ALL SELECT 2 AS a, 3 AS b FROM DUAL UNION ALL SELECT 1 AS a, 2 AS b FROM DUAL; SELECT * FROM v;
sql代碼如下:
SELECT a, b, a * b AS c FROM v ORDER BY c;
執行結果如下:
由此可見:只要能將數據查詢出來,就能根據相應的信息排序。