📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ARRAY_REDUCE



Reduces a JSON array to a single value by applying a specified Lambda expression. For more information about Lambda expression, see Lambda Expressions.

Syntax

ARRAY_REDUCE(<json_array>, <lambda_expression>)

Examples

This example multiplies all the elements in the array (2 3 4):

SELECT ARRAY_REDUCE( [2, 3, 4], (acc, d) -> acc::Int * d::Int ); -[ RECORD 1 ]----------------------------------- array_reduce([2, 3, 4], (acc, d) -> acc::Int32 * d::Int32): 24

Was this page helpful?