Kategorien:

Numerische Funktionen (Exponent und Wurzel)

SQUARE

Gibt das Quadrat eines numerischen Ausdrucks zurück (d. h. eines numerischen Ausdrucks, der mit sich selbst multipliziert wird).

Syntax

SQUARE(expr)
Copy

Returns

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

Nutzungshinweise

  • Effizienter als der Ausdruck x*x. Somit wird square(x) bevorzugt, wenn ein Gleitkommaergebnis akzeptabel ist.

Beispiele

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