Loading TOC...

MarkLogic Server 11.0 Product Documentation
cts:sum-aggregate

cts:sum-aggregate(
   $range-index as cts:reference,
   [$options as xs:string*],
   [$query as cts:query?],
   [$forest-ids as xs:unsignedLong*]
) as xs:anyAtomicType?

Summary

Returns the sum of the values given a value lexicon. This function works like cts:sum except it performs the calculation in parallel in all data nodes then aggregates the values. It generally performs better than cts:sum, especially on large clusters.

Parameters
range-index Reference to a range index.
options Same as the "options" parameter in cts:aggregate.
query Same as the "query" parameter in cts:aggregate.
forest-ids Same as the "forest-ids" parameter in cts:aggregate.

Example

xquery version "1.0-ml";

  (:
     This query assumes an element range index is configured
     in the database for the 'Amount' element.
  :)

cts:sum-aggregate(cts:element-reference(xs:QName("Amount")))

=> 733.7600000000000128

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.