请问如何将两个select的结果连在同一行上第一个结果为
  a   b  c
  1   2  3
  2   3  4第2个结果为
   a  f  e
   1  3  5
   2  4  6想要的结果为
   a  b  c  f  e
   1  2  3  3  5
   2  3  4  4  6如何实现呢?

解决方案 »

  1.   

    select * from t1 join t2 on t1.a = t2.a
      

  2.   

    select a.a,b,c,d,e
    from a inner join b on a.a=b.a
      

  3.   

    select * from (select ...)as t1 join (select...) as t2 on t1.a = t2.a
      

  4.   

    select
    ISNULL(sum(a.Payable_AMT),0),
    dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT
    from 
    B_OutInter a
    WHERE a.ActionFlag = '1'  
    AND a.OutInter_CD in ('WC0910160001') group by  a.OutInter_CDSELECT 
    a.OutInter_CD,
    U_Cname=(select u_cname from sys_user where userid='13'),
    U_MobileNo=(select U_MobileNo from sys_user where userid='13'),
    c.Outsour_NM,a.Ctct_NM,a.Tel_No,
    e.G_Cname,b.U_CName 
    FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c 
    WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and 
    a.groupid=e.groupid and a.ActionFlag = '1'  
    AND a.OutInter_CD in ('WC0910160001') 
      

  5.   

    select * from (第一个查询的查询语句)a left join (第二个查询的查询语句) b on a.a=b.a 
      

  6.   

    [code=SQL]select * from (select a.OutInter_CD ,ISNULL(sum(a.Payable_AMT),0) as Payable_AMT, 
    dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT 
    from B_OutInter a 
    WHERE a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001') group by  a.OutInter_CD 
    )a left join (
    SELECT a.OutInter_CD, U_Cname=(select u_cname from sys_user where userid='13'), 
    U_MobileNo=(select U_MobileNo from sys_user where userid='13'), 
    c.Outsour_NM,a.Ctct_NM,a.Tel_No, 
    e.G_Cname,b.U_CName 
    FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c 
    WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and 
    a.groupid=e.groupid and a.ActionFlag = '1'  
    AND a.OutInter_CD in ('WC0910160001')) b on a.OutInter_CD=b.OutInter_CD[/code]
      

  7.   

    --请参考:
    http://topic.csdn.net/u/20091013/22/a3b22548-b1ec-48de-b4f7-cf81ddeafe62.html