关于子查询中的order by子句

关于子查询中能否用order by子句,有以下两种情况:


第一种例如:

select a.col1 from a where a.col2 in (select b.col2 from b order by b.col1);
这种情况下子查询只是一个集合,并不需要进行order by。


第二种例如:

select a.col1, b.col2
from a left join 
     (select c.col1 from c  order by c.col1) b on ......

这种情况中是可以使用order by 子句的,然而却没有什么卵用。


总之在子查询中不要使用 order by 子句。因为oracle要么给你报错,要不根本不会理会你的order by。

posted @ 2015-06-03 00:31  明月镇魂  阅读(524)  评论(0编辑  收藏  举报