
op.group( [columns as columnIdentifier[]] ) as groupdef
This function specifies the grouping keys for a group as a list of zero or more columns. The result is used for building the first parameter for the prototype.groupByUnion function.
| Parameters | |
|---|---|
| columns | The columns (if any) to use as grouping keys. The columns can be named with a string or a column function such as op.col, op.viewCol, or op.schemaCol, or constructed from an expression with op.as. |
const op = require('/MarkLogic/optic');
op.fromView('main', 'expenses')
.groupByUnion(
[op.group(), op.group(['Category', 'Location'])],
op.sum("TotalAmount", "Amount")
)
.orderBy(['Category', 'Location'])
.result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.