613-518-1166 info@zimdatabases.com

ZIM Language Reference

$distinct

< All Topics

Returns the unique values from a series of successive values.

Syntax

$distinct(expression)

Parameters

expression any expression

Return Value

This function returns the unique values from a series of successive values. For each instance of its argument, $distinct returns a value that depends on the immediately previous value of the argument. If the previous and current values of the argument are equal, $distinct returns $Null. Otherwise, $distinct returns the current value of the argument.

Comments

It is important to sort the argument’s source values before using $distinct, because the value returned by the expression depends on the order in which the source values are processed.

Example

find Emps sorted by LastName

list all format LastName Salary

Prints the last names and salaries of all employees.

find Emps sorted by LastName

list all format $distinct(LastName) Salary

Prints the last names and salaries only of the employees who appear first in the list with a particular name.

find Emps sorted by LastName

list all where $distinct(LastName) is not $null format LastName

Prints a list of the last names of employees without repeating identical names.

report from Emps sorted by DeptNo LastName

break 1 DeptNo

footing

“No. of distinct last names in ” deptno

“is” $count($distinct(LastName))

endreport

When used in a BREAK heading or footing, $distinct is reset for each break group. As a result, the first record in each break group is considered to be new, even if the value of the argument to $distinct is the same as the last value in the previous group. In the above report, even if the last employee in one department is named Smith and the first employee in the next is also Smith, the values are still considered to be distinct.

See Also

Functional Expressions

INTERSECT

MINUS

UNION

Was this article helpful?
0.5 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 100%
How can we improve this article?
Table of Contents