zoukankan      html  css  js  c++  java
  • 【Oracle】取整函数trunc与五舍六入函数round

    取整语句:

    select 
        trunc(12345.678,2),
        trunc(12345.678,1),
        trunc(12345.678,0),
        trunc(12345.678,-1),
        trunc(12345.678,-2)
    from dual

    执行效果:

    SQL> select
      2      trunc(12345.678,2),
      3      trunc(12345.678,1),
      4      trunc(12345.678,0),
      5      trunc(12345.678,-1),
      6      trunc(12345.678,-2)
      7  from dual;
    
    TRUNC(12345.678,2) TRUNC(12345.678,1) TRUNC(12345.678,0) TRUNC(12345.678,-1)
    ------------------ ------------------ ------------------ -------------------
    TRUNC(12345.678,-2)
    -------------------
              12345.67            12345.6              12345               12340
                  12300

    五舍六入函数:

    select 
        round(12345.678,2),
        round(12345.678,1),
        round(12345.678,0),
        round(12345.678,-1),
        round(12345.678,-2)
    from dual

    执行效果:

    SQL> select
      2      round(12345.678,2),
      3      round(12345.678,1),
      4      round(12345.678,0),
      5      round(12345.678,-1),
      6      round(12345.678,-2)
      7  from dual;
    
    ROUND(12345.678,2) ROUND(12345.678,1) ROUND(12345.678,0) ROUND(12345.678,-1)
    ------------------ ------------------ ------------------ -------------------
    ROUND(12345.678,-2)
    -------------------
              12345.68            12345.7              12346               12350
                  12300

    END

  • 相关阅读:
    [APIO 2009] Atm
    Codeforces518 D. Ilya and Escalator
    [POJ2096] Collecting bugs
    [ZOJ3329] One Person Game
    [LightOJ1038] Race to 1 Again
    「NOI2003」逃学的小孩
    [HAOI2006] 旅行
    ☆ [POJ2411] Mondriaan's Dream 「状压DP」
    「POJ3311」Hie with the Pie
    「乘法逆元」 学习笔记
  • 原文地址:https://www.cnblogs.com/heyang78/p/15434727.html
Copyright © 2011-2022 走看看