用select case 来写吧``具体你看下```在家没环境```

解决方案 »

  1.   

    如果b1=null,b2=null,b3<>null,b3->a1,--case when 
    如果b1<>null,b2=null,b3<>null,b1->a1,b3->a2不明你的意思~update a1= case when b1 is null and b2 is null and b3 is not null then b3    
                when b1 is null and b2 is null and b3 is not null then b3 else a1 end
      

  2.   

    如果b1=null,b2=null,b3<>null,b3->a1,--case when 
    如果b1<>null,b2=null,b3<>null,b1->a1,b3->a2
    ..什么按多几下空格就发出去了?
    update a1= case when b1 is null and b2 is null and b3 is not null then b3    
                    when b1 is not  null and b2 is null and b3 is not null then b1 else a1 end,
         a2 =case  when b1 is not  null and b2 is null and b3 is not null then b3 else a2 end
      

  3.   

    我已经解决了,多谢各位,ljsql的方法很接近了,只是具体实现上还需调整
    我的sql:
    update dw_case_archives4_main 
    set a1= 
    case when b1 <> '' then b1
    else 
    (
    case when b2 <> '' then b2
    else 
    (
    case when b3 <> '' then b3
    else ''
    end
    )
    end
    )
    end update dw_case_archives4_main
    set a2 = 
    case when b2 <> '' and b2 <> a1 then b2
    else 
    (
    case when b3 <> '' and b3 <> a1 then b3
    else ''
    end
    )
    end
    where a1 is not null
    update dw_case_archives4_main
    set a3 = 
    case when b3 <> '' and b3 <> a2 then b3
    else ''
    end
    where a2 is not null
      

  4.   

    暈...<> '' 和 is not null 是不一樣的概念
      

  5.   

    <> '' 和 is not null 是不一樣的概念   确实 不是一样的概恋```