select a.nrfl, letterProcessed, letterProcessing from (select nrfl, count(docid) as letterProcessed from wsxf_document where status != 4and create_Date >='2011-11-11 00:00:00' and create_date <= '2011-12-01 23:59:59'group by nrfl) a full outer join (select nrfl, count(docid) as letterProcessing from wsxf_document where status = 4 and create_Date >='2011-11-11 00:00:00' and create_date <= '2011-12-01 23:59:59' group by nrfl) b on a.nrfl = b.nrfl请教高手,怎样把属于左右表中nrfl字段的的所有的内容在同一个字段中显示出来

解决方案 »

  1.   

    -- 如果nrfl字段是字符类型:
    select a.nrfl||' '||b.nrfl as ab_nrf1
           ....
    from ...
    -- 如果nrfl字段是整数类型:
    select to_char(a.nrfl,'999999999999999')||' '||to_char(b.nrfl,'999999999999999') as ab_nrf1
           ....
    from ...
    -- 如果nrfl字段是浮点数类型:
    select to_char(a.nrfl,'9999999999999990D999')||' '||to_char(b.nrfl,'9999999999999990D999') as ab_nrf1
           ....
    from ...
      

  2.   

    select
     (case when a.nrf1=b.nrf1 then a.nrf1
          when a.nrf1 is null and b.nrf1 is not null then b.nrf1
          when b.nrf1 is null and a.nrf1 is not null then a.nrf1
          else null end ) as nrf1
    from ......
      

  3.   

    select  nvl(a.nrf1 , b.nrf1) 
      

  4.   

    NVL(a.nrf1, b.nrf1),应该简单解决了。
    因为你的查询中有条件 a.nrf1 = b.nrf1
      

  5.   

    再补充一下,需要全外连接,即full outer join