Loading TOC...

op.on

op.on(
   $leftCol as String,
   $rightCol as String
) as ondef

Summary

Specifies an equijoin using one columndef each from the left and right rows. The result is used by the prototype.joinInner and prototype.joinLeftOuter functions.

Use op.viewCol or op.col if you need to identify columns in the two views that have the same column name.

Parameters
$leftCol The rows from the left view.
$rightCol The row set from the right view.

Example


// Calculate the total expenses for each employee and return results in order of employee number.

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

const employees = op.fromView('main', 'employees');
const expenses = op.fromView('main', 'expenses');
const totalexpenses  = op.col('totalexpenses');
const Plan =
employees.joinInner(expenses, op.on(employees.col('EmployeeID'), expenses.col('EmployeeID')))   
   .groupBy(employees.col('EmployeeID'), ['FirstName', 'LastName', expenses.col('Category'),
    op.sum(totalexpenses, expenses.col('Amount'))])
   .orderBy('EmployeeID')
Plan.result();

  

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy