Heads up! Numbers, Doubles, and Moneys are all numeric types, and can be compared and combined in functions. For example, you could multiply a money value by a number, or compare the values of a number and a double.
Doubles are double-precision numbers. They can represent any number exactly, except for numbers whose digits repeat infinitely.
Since Doubles can be either larger or more precise than what JSON parsers allow, many formats, such as JSON, serialize them as strings. For example:
The following table describes the operators that can be used with Doubles.
Operation | Description |
---|---|
< |
TRUE for numerics less than this one. |
<= |
TRUE for numerics that are less than or equal to this one. |
> |
TRUE for numerics that are greater than this one. |
>= |
TRUE for numerics that are greater than or equal to this one. |
!= |
TRUE for numerics that are not equal to this one. |
= |
TRUE for numerics that are equal to this one. |
+ |
Adds two numerics |
- |
Subtracts one numeric from another |
* |
Multiplies two numerics |
/ |
Divides one numeric by another |
% |
Returns the modulo of one numeric divided by another |
^ |
Returns the modulo of one numeric divided by another |
The following table describes the functions that can be used with text
strings.
Function Name | Description | Availability |
---|---|---|
avg(...) |
Returns the average of a given set of numbers | 2.0 and 2.1 |
between ... and ... |
Returns TRUE for values in a given range | 2.1 |
case(...) |
Returns different values based on the evaluation of boolean comparisons | 2.1 |
count(...) |
Returns a count of a given set of records | 2.0 and 2.1 |
in(...) |
Matches values in a given set of options | 2.1 |
max(...) |
Returns the maximum of a given set of numbers | 2.1 |
min(...) |
Returns the minimum of a given set of numbers | 2.1 |
not between ... and ... |
Returns TRUE for values not in a given range | 2.1 |
not in(...) |
Matches values not in a given set of options | 2.1 |
stddev_pop(...) |
Returns the population standard deviation of a given set of numbers | 2.1 |
stddev_samp(...) |
Returns a sampled standard deviation of a given set of numbers | 2.1 |
sum(...) |
Returns the sum of a given set of numbers | 2.1 |