select * from 
(select * from a where b.sales_id=c.user_id and b.x is not null) ta
(select * from a where b.sales_id=c.user_id and b.x is null) tb

解决方案 »

  1.   

    一条sql一定不可实现,用pl/sql写一段脚本吧。
      

  2.   

    thinkcat(思想猫)
    我的好像還是沒有選出我要的數據...
      

  3.   

    不好意思写错了
    select * from 
    (select * from a where b.sales_id=c.user_id and b.x is not null) ta
    (select * from b where a.sales_id=c.user_id and b.x is null) tb
      

  4.   

    現在有一個字段user_name是都是通過b.sales_id=c.user_id,a.sales_id=c.user_id 查詢的.
    到時我怎麼區分哪個是用b.sales_id=c.user_id還是a.sales_id=c.user_id查詢出來的...
      

  5.   

    这样行吗
    select * from 
    (select '空',a.* from a where b.sales_id=c.user_id and b.x is not null) ta
    (select ‘不空’,b.* from b where a.sales_id=c.user_id and b.x is null) tb
      

  6.   

    这样可以
    select * from
    (select '空',c.user_name as C1 from b,c 
    where b.sales_id=c.user_id and c.x is null
    union
    select '非空',c.user_name as C1 from a,c 
    where a.sales_id=c.user_id and c.x is not null )  
      

  7.   

    有不用from的形式嗎?不好意思,分一定給你,麻煩了...