「Oracle12c」ROUND(数値, 桁数)で指定数値を四捨五入する
環境
Oracle Database 12c Standard Edition Release 12.2.0.1.0 – 64bit Production
書式
SELECT 数値, ROUND(数値, 桁数) FROM テーブル名;
小数点以下の有効桁数を指定する引数「length」に正の数値を指定場合、
数値よりも1つ大きい数値の小数点以下の桁数で四捨五入されます。
使用例1
select round(123.4567,2) from dual
select round(123.4567,2) from dual
select round(123.4567,2) from dual
結果 123.46
使用例2
select round(123.5,2) from dual
select round(123.5,2) from dual
select round(123.5,2) from dual
結果 123.5
使用例3
select round(789.456,2) from dual
select round(789.456,2) from dual
select round(789.456,2) from dual
結果 789.46
引数「length」に負の数値を指定する場合、整数部分に丸めます
使用例4
select round(123.4567,-2) from dual
select round(123.4567,-2) from dual
select round(123.4567,-2) from dual
結果 100
使用例5
select round(789.456,-2) from dual
select round(789.456,-2) from dual
select round(789.456,-2) from dual
結果 800