SUB()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the second argument subtracted from the first argument.
USAGE
SUB([number,] number)
Argument Name | Description |
---|---|
| Two numbers to subtract or one number to negate |
DETAILS
SUB()
is a mathematical function that returns the result of subtracting the second argument from the first argument.
If the optional first argument is not provided, it defaults to 0
, resulting in a negated numeric value.
A NULL
is returned if either argument is NULL
.
EXAMPLES
SELECT SUB(59, 17), SUB(99);
+-------------+---------+
| SUB(59, 17) | SUB(99) |
+-------------+---------+
| 42 | -99 |
+-------------+---------+