カテゴリ:

数値関数 (指数とルート)

SQUARE

数値式の二乗(つまり、それ自体に乗算された数値式)を返します。

構文

SQUARE(expr)
Copy

Returns

If the input expression is of type DECFLOAT, the returned type is DECFLOAT. Otherwise, the returned type is FLOAT.

使用上の注意

  • 式 x*x よりも効率的であるため、浮動小数点の結果が受け入れられる場合は二乗(x)をお勧めします。

SELECT column1, square(column1)
FROM (values (0), (1), (-2), (3.15), (null)) v;

---------+-----------------+
 column1 | square(column1) |
---------+-----------------+
 0       | 0               |
 1       | 1               |
 -2      | 4               |
 3.15    | 9.9225          |
 [NULL]  | [NULL]          |
---------+-----------------+
Copy