Loading TOC...

MarkLogic 12 Product Documentation
op.sample

op.sample(
   aggColName as String,
   columndef as ColumnIdentifier
) as aggregatedef

Summary

This function randomly selects one non-null value of the column from the rows in the group or row set. The result is used for building the parameters used by the prototype.groupBy function.

Parameters
aggColName The name to be used for the value.
columndef The column to be aggregated. 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.

Example

const op = require('/MarkLogic/optic');

op.fromView('main', 'expenses')
   .groupBy('Category', op.sample("Sample Spent", "Amount"))
   .orderBy('Category')
   .result();

  

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