Let's assume I have three documents in MarkLogic as below,
<employee>
<name>a</name>
<age>10</age>
</employee>
<employee>
<name>b</name>
<age>10</age>
</employee>
<employee>
<name>c</name>
<age>10</age>
</employee>
Documents uris - /employee/a, /employee/b, /employee/c respectively.
I have created path range index for "/employee/age"
as int
scalar stype.
My Requirement is - Get the Sum of all the values of path range index "/employee/age"
.
I tried - sum(cts:values(cts:path-reference("/employee/age")))
but it is returning 10 as output sum here I am expecting 30 as output sum.
What will be the solution for the above problem?