Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Count (link path) (OLAP)

JoeWinter edited this page Sep 18, 2014 · 2 revisions

[Table of Contents](https://github.com/dell-oss/Doradus/wiki/OLAP Databases: Table-of-Contents) | Previous | Next
Doradus Query Language: Count (link path)


The `COUNT` function can be used on a link field or a field path ending with a link. It produces a count of the link values relative to each perspective object; the count can then be used in a comparison clause. For example:

COUNT(DirectReports) > 0

This clause returns true for a perspective object if it has at least one DirectReports value.

When a link path is used, the number of leaf link values are counted. For example:

COUNT(InternalRecipients.MessageAddress.Person) > 5

This clause returns true if the total of all InternalRecipients.MessageAddress.Person values is > 5. Some InternalRecipients may not have a MessageAddress value, and some MessageAddress objects may not have a Person value.

The link values to be included in a COUNT function can be filtered by using the WHERE function. For example:

COUNT(DirectReports.WHERE(LastName=Smith)) > 0

This clause returns true for objects that have at least one direct report whose last name is Smith. Note that the WHERE expression is specified immediately after the link name to be filtered. The parameter to the WHERE function is an expression relative to the link field. In this example, LastName must be a scalar field belong to DirectReports' extent table.

The parameter to the WHERE function can be a link path. For example:

COUNT(InternalRecipients.WHERE(MessageAddress.Person.LastName=Smith)) > 5

This clause returns true for messages that have at least 5 internal recipients whose last name is Smith.

Clone this wiki locally