按计算列排序
如果要对计算列排序,可以为计算列指定别名,然后按别名排序。
创建测试用表:
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;
执行结果如下:
由此可见:只要能将数据查询出来,就能根据相应的信息排序。