
op:add( $left as item(), $right as item() ) as map:map
This function returns the sum of the specified numeric expressions. In expressions, the call should pass the result from an op:col function to identify a column.
The op:add function differs from the op:sum function in that it operates on operates on multiple column values in a row, rather than a group of rows.
As a convenience, you can pass a sequence of any number of expressions as the
first argument: op:add((expr1, expr2, ..., exprN))
| Parameters | |
|---|---|
| $left | The left value expression. It can be a number, a column function such as op:col, op:view-col, or op:schema-col, or expressions. |
| $right | The right value expression. It can be a number, a column function such as op:col, op:view-col, or op:schema-col, or expressions. |
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";
let $employees := op:from-view("main", "employees")
return $employees
=> op:offset-limit(op:param('start'), op:param('length'))
=> op:select(('EmployeeID',
op:as('incremented',
op:add(op:col('EmployeeID'),
op:param('increment')))
))
=> op:result((), map:entry("start",1)=>map:with("length",2)=>map:with("increment",1))
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";
let $employees := op:from-view("main", "expenses")
return $employees
=> op:select(('EmployeeID',
op:as('incremented',
op:add((op:col('Entertainment'), op:col('Health'), op:('Transport'))))
))
=> op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.