select round(0,2) from dual 为啥输出的是 0 而不是 0.00 呢?另外还有啥办法可以得到输出结果 0.00 呢?

解决方案 »

  1.   

    round 是 四舍五入 又不是按格式进位的 
      

  2.   

    select round(0.2456,2) from dual  ---
    0.25
      

  3.   

    select decode(to_char(round(0,2),'fm999999999999999999.00'),0,'0.00') from dual
      

  4.   

    SELECT (dbms_random.value(0,2)) from dual;
      

  5.   

    -- 任何为0的数是不会显示小数位的!select round (0,2) from dual;select round (18.369,2) from dual;
      

  6.   


    --练习 互相提升
      1* select to_char(round(0,2),'fm99990.00') from dual
    SQL> /TO_CHAR(R
    ---------
    0.00
      

  7.   

    round是功能是四舍五入,并非格式化数据,格式化数据请用to_char,并且指定相应的格式符
    格式符参考