现在要求统一调价,比如会员价980,现在统一上调10% 价格变成 1078 现在想让他变成 1080现在要求统一调价,比如会员价55,现在统一上调10% 价格变成 60.5 现在想让他变成 60现在要求统一调价,比如会员价9800,现在统一上调10% 价格变成 10780 现在想让他变成 10800 (这个若不好实现,可以忽略这一条)可以用sql 实现吗,假设这个字段是price

解决方案 »

  1.   

    select ceil(price/10)*10 from tableA
      

  2.   

       declare 
        v_cel number(7,0);
    v_tt number(6,1);
    begin 
     v_cel:=&n;
     v_tt :=v_cel/10;
     dbms_output.put_line('ceiling is:'||ceil(v_tt)*10);
    end ;
    /
      

  3.   

    看一下这样可以不with tbl as
    (
        select 980 as price from dual
         union all
        select 49 as price from dual
         union all
        select 55 as price from dual
         union all
        select 9800 as price from dual
         union all
        select 98000 as price from dual
    )select round(trunc(price * 1.1) / power(10, case when length(price) - 2 < 1 then 1 else length(price) - 2 end)) * power(10, case when length(price) - 2 < 1 then 1 else length(price) - 2 end) as price from tbl;
         PRICE
    ----------
          1080
            50
            60
         10800
        108000