select A.積月,B.受注本数 
from 
(select '2004' as 
union all select '2003' 
union all select '2002' 
union all select '2001') A left join 注文仮置明細 B
where A.積月=B.積月
order by 積月

解决方案 »

  1.   

    select A.積月,B.受注本数 
    from 
    (select '2004' as 積月
    union all select '2003' 
    union all select '2002' 
    union all select '2001') A left join 注文仮置明細 B
    where A.積月=B.積月
    order by 積月
      

  2.   

    select distinct 積月 into #year from 注文仮置明細 
    select a.積月 ,b.受注本数 from #year a,注文仮置明細  b order by a.積月
      

  3.   

    select distinct 積月 into #year from 注文仮置明細 
    select a.積月 ,b.受注本数 from #year a,注文仮置明細  b 
           where a.積月 = b.積月 order by a.積月
      

  4.   

    select b.積月,a.受注本数 from 注文仮置明細 a right join (select 2004 tt union all select 2003 tt union all select 2002 tt union all select 2001 tt) b on a.積月=b.積月 order by b.積月
      

  5.   

    select b.tt,a.受注本数 from 注文仮置明細 a right join (select 2004 tt union all select 2003 tt union all select 2002 tt union all select 2001 tt) b on a.積月=b.tt order by b.tt
      

  6.   

    如果换成在oracle里面执行?应该怎么写?
      

  7.   

    select A.積月,B.受注本数 
    from 
    (select '2004' as 積月
    union all select '2003'  as 積月
    union all select '2002'  as 積月
    union all select '2001' as 積月) A left join 注文仮置明細 B
    where A.積月=B.積月
    order by A.積月