MarkLogic 12 EA 1 Product Documentation
op:asc

op:asc(
   $column as item()
) as map:map

Summary

This function sorts the rows by the values of the specified column in ascending order. The results are used by the op:order-by function.

Parameters
$column The column by which order the output.

Example

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:asc(op:view-col("employees", "EmployeeID")))
   => op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy