op:on( $leftCol as item(), $rightCol as item() ) as map:map
Specifies an equijoin using one columndef each from the left and right rows. The result is used by the op:join-inner, op:join-left-outer, and op:join-full-outer, and functions.
Use op:view-col or op:col if you need to identify columns in the two views that have the same column name.
The default collation for string values in a TDE template is codepoint
.
If you are having problems joining columns that use a different collation, you will need
to change the TDE template to use a matching collation, or change the appropriate range
indexes to use codepoint
.
Parameters | |
---|---|
$leftCol | The rows from the left view. |
$rightCol | The row set from the right view. |
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; let $employees := op:from-view("main", "employees") let $expenses := op:from-view("main", "expenses") let $totalexpenses := op:col("totalexpenses") return $employees => op:join-inner($expenses, op:on( op:view-col("employees", "EmployeeID"), op:view-col("expenses", "EmployeeID"))) => op:group-by(op:view-col("employees", "EmployeeID"), ("FirstName", "LastName", op:view-col("expenses", "Category"), op:sum($totalexpenses, op:view-col("expenses", "Amount")))) => op:order-by(op:view-col("employees", "EmployeeID")) => op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.