MarkLogic 12 EA 1 Product Documentation
op:count

op:count(
   $outCol as item(),
   [$inCol as item()],
   [$options as map:map]
) as map:map

Summary

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 op:group-by function.

Parameters
$outCol The name to be used for the column values.
$inCol The columns to be counted.
$options The options can take a values key with a 'distinct' value to count the distinct values of the column.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

let $expenses := op:from-view("main", "expenses")

return $expenses
	          => op:group-by("Category", op:count("Number of Expenses", "Amount", map:entry('values', 'distinct')))
	          => op:order-by("Category")
	          => op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy