MarkLogic Server 11.0 Product Documentation
op:group-concat

op:group-concat(
   $outCol as item(),
   $inCol as item(),
   [$options as map:map?]
) as map:map

Summary

This function concatenates the non-null values of the column for the rows in the group or row set. The result is used for building the parameters used by the op:group-by function.

Parameters
$outCol The name to be used for column with the concatenated values.
$inCol The name of the column with the values to be concatenated for the group.
$options The options can take a values key with a distinct value to average the distinct values of the column. In addition to the values key, the options can take a separator key specifying a separator character. The value can be a string or placeholder parameter.

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:group-concat("Spent", "Amount", map:entry("separator","-")
                   => map:with("values","distinct")))
	     => op:order-by("Category")
	     => op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy