want to sum inner element with JSON in using N1QLCouchbase

前端 未结 1 1005
不知归路
不知归路 2021-01-27 09:15

when I run below query

SELECT * FROM myBucket WHERE ANY x IN transactions SATISFIES x.type in [0,4] END;

Result:

{
  \"_type\"         


        
相关标签:
1条回答
  • 2021-01-27 09:32

    transactions[*].amount this is return array so first need to user array function

    ARRAY_SUM
    

    than use sum like below.

    SELECT sum(ARRAY_SUM(transactions[*].amount)) FROM Inheritx WHERE ANY x IN transactions SATISFIES x.type in [0,4] END;
    
    0 讨论(0)
提交回复
热议问题