
op.count( aggColName as String, [columndef as ColumnIdentifier], [options as Object] ) as aggregatedef
This function counts the rows where the specified input column has a value. If the input column is omitted, all rows in the group or row set are counted. The result is used for building the parameters used by the prototype.groupBy function.
| Parameters | |
|---|---|
| aggColName | The name to be used for the column values. |
| columndef | The columns to be counted. The column 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 the op.as function. |
| options |
The options can take a values key with a
'distinct' value to count the distinct values of
the column.
|
const op = require('/MarkLogic/optic');
op.fromView('main', 'expenses')
.groupBy('Category', op.count("Number of Expenses", "Amount", {values: 'distinct'}))
.orderBy('Category')
.result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.