op.asc( columndef as String ) as sortdef
This function sorts the rows by the values of the specified column in ascending order. The results are used by the prototype.orderBy function.
Parameters | |
---|---|
columndef | The column by which order the output. |
// Calculate the total expenses for each employee and return results in order of total // expenses, lowest to highest. 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(op.asc('totalexpenses')) Plan.result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.