TOP_N

When used within a query the function produces a recordset that contains the top or bottom n records based on their values for a given numeric field.

When used within a virtual field the function will return True for records that match the criteria given and False for records that do not.

TOP_N ( <table_name or expression>, <field>, <nvalue> [, <reverse>] )
  • table name or expression: Can be either a table name, or an expression (a query string or another query domain function) resulting in a recordset.
  • field: The numeric field on which to order the records
  • nvalue: The number of records to return
  • reverse: Boolean value to determine whether the records with the Highest values for the field are selected (False) or the Lowest values for the field are selected (True)

Example: create a query at the CUSTOMER level

TOP_N(CUSTOMER,CUSTOMER.INCOME,3,False)