
op:named-group( $name as xs:string, [$columns as item()*] ) as map:map
This function specifies the grouping keys for a group as a named list of zero or more columns. The result is used for building the first parameter for the op:group-to-arrays function.
| Parameters | |
|---|---|
| $name | The name for the list of grouping keys. |
| $columns | The columns (if any) to use as grouping keys. The columns can be named with a string or a a column function such as op:col, op:view-col, or op:schema-col, or constructed from an expression with op:as. |
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";
op:from-view("main", "expenses")
=> op:group-to-arrays(
(op:named-group('total'), op:named-group('byCategoryLocation', ("Category", "Location"))),
op:sum("TotalAmount", "Amount"))
=> op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.