ANY_VALUE
Description
The ANY_VALUE function is used to randomly select and return a value from a set of data. When processing multiple data rows, this function can simplify queries and improve efficiency.
Parameter Description
- expr: An expression of any numeric type (such as tinyint, smallint, int, bigint, float, double, decimal) or string type (such as string, char, varchar) or complex type.
Return Result
- Returns a value of the same type as the input parameter expr.
- If the input parameter contains null values, null values will also be included in the calculation.
Usage Example
- Randomly select a value from a set of integers:
- Randomly select a value from data containing null values: