Loading TOC...

MarkLogic 9 Product Documentation
op.as

op.as(
   column as String,
   expression as String
) as columnBinding

Summary

This function defines a column by assigning the value of an expression over the rows in the row set.

Parameters
column The name of the column to be defined. This can be either a string or the return value from op.col, op.viewCol, or op.schemaCol.
expression The expression used to define the value the column.

Example


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

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

  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.