unique — aggregate function to return a list of the specified number of unique items in the aggregate window.


unique (expr, int numuniq)


This function takes the name of a column in the incoming data (or a StreamBase expression that contains a column name), plus an integer to specify the number of unique results desired. The function returns a list containing the numuniq number of unique column values, whose data type is the same as the queried column.

The unique() function maintains an exact list of unique values until numuniq is reached, and does not report changes as the number of values added exceeds numuniq. If a value in the reported unique list is removed, it is replaced by some other unique value, if one exists. If there are more than numuniq values, there is no guarantee which numuniq values are reported.

You can use unique() in SNAPSHOT or SNAPSHOT_AND_CONTINUOUS queries where the list return type is handled normally. However, when using unique() as part of an author-time aggregation, you must wrap the unique() function in joinlist() to convert the returned list to a formatted string.


This LiveView aggregate function is based on the unique aggregate function in the StreamBase expression language.

See the related LiveView aggregate function joinlist().