have a try:update a set a.c=(select case when a.c<b.c then b.c else a.c end from b)
where exists( select 1 from b where a.a=b.a and a.b=b.b) 

解决方案 »

  1.   

    8i的话
    需要吧case语句换成decode(sign(a.c-b.c),...)
      

  2.   

    update a set a.a=(select b.a from b    where a.a=b.a and a.b=b.b) ,
    a.b=(select b.b from b    where a.a=b.a and a.b=b.b) ,
    a.c=(select decode(a.c >b.c,1,a.c,b.c) as c from b    where a.a=b.a and a.b=b.b) ,
    a.d=(select b.d from b    where a.a=b.a and a.b=b.b) 
    但是我不知道怎么比较两个数的大小
      

  3.   

    update a set a.a=(select b.a from b    where a.a=b.a and a.b=b.b) ,
    a.b=(select b.b from b    where a.a=b.a and a.b=b.b) ,
    a.c=(select decode(sign(a.c>b.c),1,a.c,-1,b.c) as c from b    where a.a=b.a and a.b=b.b) ,
    a.d=(select b.d from b    where a.a=b.a and a.b=b.b)
    学习楼上的,哈哈
      

  4.   

    其实a.c 和b.c是两日期,比较它们的大小是不是用dateDiff?
    不过这好像是vb里面的,不知道sql里有没这样的函数阿
      

  5.   

    想不通,你们怎么不这样:
    update a set a.a= b.a
    a.b=b.b
    a.c=(select decode(a.c >b.c,1,a.c,b.c) as c from b where a.a=b.a and a.b=b.b),
    a.d=b.d
    where a.a=b.a and a.b=b.b这样效率不是更高