select 
case when (a.name=b.name) then (select * from x) 
     when (a.name>b.name) then (select * from y) 
else (select * from z)
end 
from a,b 
此语句在ORACLE8.15及以下版本中如何运行或更改

解决方案 »

  1.   

    decode
    不过你这有些复杂,可能需要改动一下
      

  2.   

    decode中能不能使用select语句我还没用过,不知道可不可以用if then else?
      

  3.   

    不知道你想在什么情况下使用。(存储过程还是执行SQL)而且就你目前写的内容,我不知道你想做什么啊。最好写出原句看看是否可以简化或调整。
      

  4.   

    decode + sign可以解决但是你的语句看不懂
      

  5.   

    分解为三个语句就ok了。
    ------------------------------------------------------
    OTN 中文技术论坛
    OCP 认证 Oracle学习资料
    欢迎各路新手和高手光临!
    http://211.99.196.144:8090/forum1/frontshow/index.jsp
      

  6.   


    select * from x where exists(select 1 from a,b where a.name=b.name)
    union all
    select * from y where exists(select 1 from a,b where a.name>b.name)
    union all
    select * from z where not exists(select 1 from a,b where a.name=b.name or a.name>b.name)
      

  7.   

    用DECODE函数,很方便的啊!我现在忙,一会给你写啊!
      

  8.   

    不过你的语句好像有点不通啊,你是不是没用过ORACLE啊,那你就用中文把意思说一下啊!