create table #A (a1 int ,b1 int)
create table #B (a2 int ,b2 int ,c2 int ,d2 int  )
insert into #A values (1,10)
insert into #A values (2,20)
insert into #A values (3,30)
insert into #b values (1,21,31,41)
insert into #b values (2,22,32,42)select #A.a1,#A.B1,#B.c2,#B.d2
from #A left outer join #B on #A.a1=#B.a2drop table #A
drop table #b

解决方案 »

  1.   

    以上运行结果:
    1 10 31 41
    2 20 32 42
    3 30 NULL NULL
      

  2.   

    select A.a1,A.B1,B.c2,B.d2
    from A left join B on A.a1=B.a2
      

  3.   

    --合同号
    select opprno as  物料号 ,substring(opprno,3,4) +" X "+substring(opprno,7,4) as 规格,opmfno as MO号 ,oppmid as 属性代码,oppvbu as 合同号 
    into #hth
    from mipwop
    where left(opmfno,2)='22' and oppmid='95100'这样我得到的"规格"列值如果是:2445 X 1003
    怎样能变成244.50 X 10.03 呢?我使用cast(cast(substring(opprno,3,4) as decimal(6,2)) as varchar(6)) +" X "+cast(cast(substring(opprno,7,4) as decimal(5,2)) as varchar(5)) 
    提示:类型转换益处错误再麻烦大家