SELECT ISNULL(a.id, b.id) AS id, isnull(a1.xx,0) as xx, isnull(a2.zz,0) AS zz from a full outer join b on a.id=b.id

解决方案 »

  1.   

    to :inalover(奇遇) 结果不对呀!
    1          100.0 20.0
    1          100.0 30.0
    1          200.0 20.0
    1          200.0 30.0
    1          300.0 20.0
    1          300.0 30.0
    关注!
      

  2.   

    两个表之间没有确定的关联关系,简单的SQLA是无法实现的。
    必须增加关联条件。
      

  3.   

    to strongsun(我会1+1了!!) :
    besides some writingerror,should be right.....
    Why did u get that result??SELECT ISNULL(a.id, b.id) AS id, ISNULL(a.xx, 0) AS xx, ISNULL(b.zz, 0) AS zz
    FROM a FULL OUTER JOIN
          b ON a.id = b.id
      

  4.   

    上面的那个SQL我也用过,不行啊,有没有别的办法,我不想再增加一个字段了
      

  5.   

    不想使用增加字段,有没有什么办法在sql里内欠编程进行计算的
      

  6.   

    在oracle中用rownum() over()函数可以实现你要的功能,但不知道sql server中能不能做分组取行号