카테고리:

숫자 함수 (지수 및 근)

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보다 효율적이므로, 부동 소수점 결과가 허용되는 경우 square(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