declare @i int
set @i=1
while @i=1
   update tablename set price=price+0.5 where price<53-0.5

解决方案 »

  1.   

    --按错了,接着
    declare @i int
    set @i=1
    while @i=1
    begin
       update tablename set price=price+0.5 where price<53-0.5
     
      if cast((select avg(price) from tablename)/0.5 as int)=cast(24.5/0.5 as int) 
          @i=0
      end
      

  2.   

    while  (select sum(price)/sum(1) from table )<24.5 
    begin
    update table set price = case when price<53 then price*1.5 else price endupdate  table set price=49.5 where price>53 
    end
      

  3.   

    while  (select sum(price)/sum(1) from table )<24.5 
    begin
    update table set price = case when price<53 then price+0.5 else price endupdate  table set price=49.5 where price>53 
    end
      

  4.   

    while(select avg(价格) from 表)<24.5
    begin
     update 表 set 价格=价格+0.5
     if(select max(价格)+0.5 from 表)>53
       break
     else
       continue
    end
    揭贴吧,完全正确,并且是最简练清晰的