NEG

2025-11-14 07:33:32  Updated

Syntax

NEG(expr)

Purpose

NEG() performs the complement operation on the operand. The function subtracts the operand from zero and then returns the result.

Comparison operations are supported. The comparison result is a Boolean value, which is converted into a numeric value. The result is 1 (TRUE) or 0 (FALSE). The complement operation is then performed on the result.

Examples

obclient> SELECT NEG(1), NEG(1+1), NEG(2*3), NEG(1=1), NEG(5<1);
+--------+----------+----------+----------+----------+
| NEG(1) | NEG(1+1) | NEG(2*3) | NEG(1=1) | NEG(5<1) |
+--------+----------+----------+----------+----------+
|     -1 |       -2 |       -6 |       -1 |        0 |
+--------+----------+----------+----------+----------+
1 row in set

Contact Us