Number Functions
- reference
Number functions are functions that are performed on a numeric field.
TRUNC(expression [, digits ])
Description
Truncates the number to the given number of integer digits to the right of the decimal point (left
if digits
is negative).
Digits
is zero if not given.
Example
Query
SELECT
AVG(reviews.rating) / 5 AS normalizedRating,
ROUND((avg(reviews.rating) / 5), 2) AS roundedRating,
TRUNC((avg(reviews.rating) / 5), 3) AS truncRating
FROM reviews AS reviews
WHERE reviews.customerId = "customer62"
Returns
Result
{
"results": [
{
"normalizedRating": 0.42000000000000004,
"roundedRating": 0.42,
"truncRating": 0.42
}
]
}