AccessPlan.prototype.orderBy( orderdef as String ) as ModifyPlan
This method sorts the row set by the specified order definition.
Parameters | |
---|---|
orderdef | The specified column or sortdef output from the op.asc or op.desc function. |
orderBy
is a method of the following classes:
The library functions that return a sortdef
used by the
orderdef
parameter are as follows:
// 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();