SQL Server ROUND()関数
例
数値を小数点以下第2位に四捨五入します。
SELECT ROUND(235.415, 2) AS RoundValue;
定義と使用法
ROUND()関数は、数値を指定された小数点以下の桁数に丸めます。
ヒント:FLOOR( )関数と CEILING()関数も確認してください。
構文
ROUND(number, decimals, operation)
パラメータ値
Parameter | Description |
---|---|
number | Required. The number to be rounded |
decimals | Required. The number of decimal places to round number to |
operation | Optional. If 0, it rounds the result to the number of decimal. If another value than 0, it truncates the result to the number of decimals. Default value is 0 |
技術的な詳細
で動作します: | SQL Server(2008以降)、Azure SQLデータベース、Azure SQLデータウェアハウス、Parallel Data Warehouse |
---|
その他の例
例
数値を小数点以下2桁に四捨五入し、操作 パラメーターも使用します。
SELECT ROUND(235.415, 2, 1) AS RoundValue;
例
数値を小数点以下-1桁に丸めます。
SELECT ROUND(235.415, -1) AS RoundValue;