CEIL
説明
浮動小数点数と固定小数点数の小数を指定された桁数に切り上げ、切り上げされた浮動小数点数または固定小数点数を返します。
構文
CEIL(<a>[, <d>])
パラメータ
| Parameter | デスクリプション |
|---|---|
<a> | 浮動小数点(Double)または固定小数点(Decimal)パラメータで、丸め処理を行う対象のパラメータを示す |
<d> | オプション、整数、対象の桁数への丸め処理を示す。正の数は小数点以下への丸め処理を意味し、負の数は小数点以上への丸め処理を意味し、0は整数への丸め処理を示す。未入力の場合、<d> = 0と同等である。 |
Return Value
以下のルールに従って、<a>以上の最小の丸められた数を返します。
1/(10^d)桁に丸める、つまり結果を1/(10^d)で割り切れるようにします。1/(10^d)が正確でない場合、丸め桁は対応するデータ型の最も近い数になります。
Decimal型のエントリ<a>について、それがDecimal(p, s)型であると仮定すると、戻り値は以下のようになります:
Decimal(p, 0)、<d> <= 0の場合Decimal(p, <d>)、0 < <d> <= sの場合Decimal(p, s)、<d> > sの場合
Alias
- DCEIL
- CEILING
Examples
select ceil(123.456);
+---------------+
| ceil(123.456) |
+---------------+
| 124 |
+---------------+
select ceil(123.456, 2);
+------------------+
| ceil(123.456, 2) |
+------------------+
| 123.46 |
+------------------+
select ceil(123.456, -2);
+-------------------+
| ceil(123.456, -2) |
+-------------------+
| 200 |
+-------------------+
select ceil(123.45, 1), ceil(123.45), ceil(123.45, 0), ceil(123.45, -1);
+-----------------+--------------+-----------------+------------------+
| ceil(123.45, 1) | ceil(123.45) | ceil(123.45, 0) | ceil(123.45, -1) |
+-----------------+--------------+-----------------+------------------+
| 123.5 | 124 | 124 | 130 |
+-----------------+--------------+-----------------+------------------+
select ceil(x, 2) from ( select cast(123.456 as decimal(6,3)) as x from numbers("number"="5") )t;
+------------+
| ceil(x, 2) |
+------------+
| 123.46 |
| 123.46 |
| 123.46 |
| 123.46 |
| 123.46 |
+------------+