Update test
set test.money=a.money
from (select 
case 
when mytime.count<=10 and mytime.count >0 then mymoney.money1
when mytime.count<=20 and mytime.count >0 then mymoney.money2
when mytime.count<=30 and mytime.count >0 then mymoney.money3
when and mytime.count>30 or and mytime.count <0 then =0 
else mymoney.money4 
end 
from mytime,mymoney)a

解决方案 »

  1.   

    Update test
    改一下:
    set test.money=a.money
    from (select 
    case 
    when mytime.count<=10 and mytime.count >0 then mymoney.money1
    when mytime.count<=20 and mytime.count >0 then mymoney.money2
    when mytime.count<=30 and mytime.count >0 then mymoney.money3
    when and mytime.count>30 then  mymoney.money4
    else 0
    end 
    from mytime,mymoney)a
      

  2.   

    case when mytime.count between 0 and 10 then mymoney.money1
         when mytime.count between 11 and 20 then mymoney.money2
         when mytime.count between 21 and 30 then mymoney.money3
         when mytime.count>30 then mymoney.money4
    else 0 end
      

  3.   

    Update test
    set test.money=a.money
    from (select 
    case 
    when mytime.count<=10  and mytime.count>0 then mymoney.money1
    when mytime.count<=20  and mytime.count>0 then mymoney.money2
    when mytime.count<=30  and mytime.count>0 then mymoney.money3
    when mytime.count>30   then mymoney.money4
    else 0
    end 
    from mytime,mymoney)a
      

  4.   

    Update test
    set test.money=a.money
    from (select 
    case 
    when mytime.count<=10 and mytime.count >0 then mymoney.money1
    when mytime.count<=20 and mytime.count >0 then mymoney.money2
    when mytime.count<=30 and mytime.count >0 then mymoney.money3
    when mytime.count>30 then  mymoney.money4
    else 0
    end 
    from mytime,mymoney)a
      

  5.   

    你可以用case嵌掏if mytime.count>0 then
    case mytime.count
    when mytime.count<=10 then mymoney.money1
    when mytime.count<=20 then mymoney.money2
    when mytime.count<=30 then mymoney.money3
    else mymoney.money4 
    end 
    else 0==>case when mytime.count>0 then (case mytime.count
    when mytime.count<=10 then mymoney.money1
    when mytime.count<=20 then mymoney.money2
    when mytime.count<=30 then mymoney.money3
    else mymoney.money4 
    end ) else 0 end