按计算列排序

如果要对计算列排序,可以为计算列指定别名,然后按别名排序。

创建测试用表:

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;

执行结果如下:

由此可见:只要能将数据查询出来,就能根据相应的信息排序。

posted on 2015-10-14 10:37  奈何作贼  阅读(382)  评论(1编辑  收藏  举报

导航