Oracle® OLAP DML Reference 10g Release 2 (10.2) Part Number B14346-02 |
|
|
View PDF |
The COUNT function counts the number of TRUE
values of a Boolean expression. It returns 0
(zero) when no values of the expression are TRUE
.
Return Value
INTEGER
Syntax
COUNT(boolean-expression [dimension...])
Arguments
The Boolean expression whose TRUE
values are to be counted.
The name of a dimension of the result; or, the name of a relation between one of the dimensions of boolean-expression and another dimension that you want as a dimension of the result.
By default, COUNT returns a single YES
or NO
value. When you indicate one or more dimensions for the result, COUNT tests for TRUE
values along the dimensions that are specified and returns an array of values. Each dimension must be either a dimension of boolean-expression or related to one of its dimensions.
Tip:
When you specify a dimension that is not an actual dimension of boolean-expression, but, instead, is dimension that is related to a dimension of boolean-expression and when there is more than one relation between the two dimensions, Oracle OLAP uses the default relation between the dimensions to perform the calculation. (See the RELATION command for more information on default relations.) When you do not want Oracle OLAP to use this default relation, specify the related dimension by specifying the name of a specify relation.Notes
The Effect of NASKIP on COUNT
COUNT is affected by the NASKIP option. When NASKIP is set to YES
(the default), COUNT returns the number of TRUE
values of the Boolean expression, regardless of how many other values are NA
. When NASKIP is set to NO
, COUNT returns NA
when any value of the expression is NA
. When all the values of the expression are NA
, COUNT returns NA
for either setting of NASKIP.
Examples
Example 11-30 Counting True Values by District
You can use COUNT to find the number of months in which each district sold more than 2,000 units of sportswear. To obtain a count for each district, specify district
as the dimension for the result.
LIMIT product TO 'SPORTSWEAR' REPORT HEADING 'Count' COUNT(units GT 2000, district)
The preceding statement statements produce the following output.
DISTRICT Count -------------- ---------- Boston 0 Atlanta 23 Chicago 11 Dallas 24 Denver 7 Seattle 0