4D v19

entitySelection.distinct( )

Home

 
4D v19
entitySelection.distinct( )

entitySelection.distinct( )  


 

The entitySelection.distinct( ) method returns a collection containing only distinct (different) values from the attributePath in the entity selection.

The returned collection is automatically sorted. Null values are not returned.

In the attributePath parameter, pass the entity attribute whose distinct values you want to get. Only scalar values (text, number, boolean, or date) can be handled. If the attributePath is an object attribute that contains values of different types, they are first grouped by type and sorted afterwards. Types are returned in the following order:

  1. booleans
  2. strings
  3. numbers
  4. dates

By default, a non-diacritical evaluation is performed. If you want the evaluation to be case sensitive or to differentiate accented characters, pass the dk diacritical constant in the option parameter.

An error is returned if:

Example  

You want to get a collection containing a single element per country name:

 C_COLLECTION($countries)
 $countries:=ds.Employee.all().distinct("address.country")



See also 

entitySelection.count( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - EntitySelection

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)