Sie sind auf Seite 1von 3

ANY http://stanford.edu/dept/itss/docs/oracle/10g/olap.101/b10339/x_agmap...

Skip Headers

Oracle® OLAP DML Reference


10g Release 1 (10.1)
Part Number B10339-02 Home Book List Contents Index Master Index Feedback

View PDF

Previous Next

ANY
The ANY function returns YES when any values of a Boolean expression are TRUE, or NO when none of
the values of the expression are TRUE.

Return Value

BOOLEAN.

Syntax

ANY(boolean-expression [[STATUS] dimensions])

Arguments

boolean-expression

The Boolean expression to be evaluated

STATUS

Can be specified when one or more of the dimensions of the result of the function are not
dimensions of the Boolean expression. (See the description of the dimensions argument.) When you
specify the STATUS keyword when this is not the case, Oracle OLAP produces an error.

In cases where one or more of the dimensions of the result of the function are not dimensions of the
Boolean expression, the STATUS keyword might be required in order for Oracle OLAP to process
the function successfully, or the STATUS keyword might provide a performance enhancement. See
"The STATUS Keyword".

dimensions

The dimensions of the result. By default, ANY returns a single YES or NO value. When you indicate
one or more dimensions for the result, ANY 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. When it is a related dimension, you can specify the
name of the relation instead of the dimension name. This makes it possible for you to choose which
relation is used when there is more than one.

Notes

NA Values

When the Boolean expression involves an NA value, ANY returns a YES or NO result when it can, as shown

1 of 3 9/2/2009 5:06 PM
ANY http://stanford.edu/dept/itss/docs/oracle/10g/olap.101/b10339/x_agmap...

in Table 7-6, "Results of ANY with Boolean Expressions with NA Values".

Table 7-6 Results of ANY with Boolean Expressions with NA Values

Boolean Expression Result


NA EQ NA YES
NA NE NA NO
NA EQ non-NA NO

NA NE non-NA YES
NA AND NO NO
NA OR YES YES

However, in cases where a YES or NO result would be misleading, ANY returns NA. For example, when you
test whether an NA value is greater than a non-NA value, ANY returns NA.

The Effect of NASKIP

ANY is affected by the NASKIP option. When NASKIP is set to YES (the default), ANY ignores NA
values and returns YES when any of the values of the expression that are not NA are TRUE and returns NO
when none of the values are TRUE. When NASKIP is set to NO, ANY returns NA when any value of the
expression is NA. When all the values of the expression are NA, ANY returns NA for either setting of
NASKIP.

Data with a Type of DAY, WEEK, MONTH, QUERTER, or YEAR

When boolean-expression is dimensioned by a dimension with a type of DAY, WEEK, MONTH,


QUARTER, or YEAR, you can specify any other dimension of this type as a related dimension. Oracle
OLAP uses the implicit relation between these dimensions. To control the mapping of one of these
dimension to another (for example, from weeks to months), you can define an explicit relation between
the dimensions and specify the name of the relation as the dimension argument to the ANY function.

For each time period in the related dimension, Oracle OLAP tests the data values for all the source time
periods that end in the target time period. This method is used regardless of which dimension has the more
aggregate time periods.

The STATUS Keyword

When one or more of the dimensions of the result of the function are not dimensions of the Boolean
expression, Oracle OLAP creates a temporary variable to use while processing the function. When you
specify the STATUS keyword, Oracle OLAP uses the current status instead of the default status of the
related dimensions for calculating the size of this temporary variable.

When the size of the temporary variable for the results of the function would exceed 2 gigabytes, you
must specify the STATUS keyword in order for Oracle OLAP to execute the function successfully. When
the dimensions of the Boolean expression are limited to a few values and are physically fragmented, you
can specify the STATUS keyword to improve the performance of the function.

When you use the ANY function with the STATUS keyword in an expression that requires going outside
of the status for results (for example, with the LEAD or LAG functions or with a qualified data
reference), the results outside of the status will be returned as NA.

2 of 3 9/2/2009 5:06 PM
ANY http://stanford.edu/dept/itss/docs/oracle/10g/olap.101/b10339/x_agmap...

Related Statements

COUNT, EVERY, and NONE.

Examples

Example 7-27 Testing for Any True Values by District

Suppose you want to find out which districts had at least one month with sales greater than $150,000 for
sportswear. You use the ANY function to determine whether the Boolean expression (sales GT 150000)
is TRUE for any month. To have the result dimensioned by district, specify district as the second
argument in the ANY function.
LIMIT product TO 'SPORTSWEAR'
REPORT HEADING 'High Sales' ANY(sales GT 150000, district)

The preceding statements produce the following output.


DISTRICT High Sales
-------------- ----------
Boston NO
Atlanta YES
Chicago NO
Dallas YES
Denver NO
Seattle NO

Example 7-28 Testing for Any True Values by Region

You might also want to find out which regions had at least one month in which at least one district had
sportswear sales greater than $150,000. Since the region dimension is related to the district dimension,
you can specify region instead of district as a dimension for the results of ANY.
report heading 'High Sales' any(sales gt 150000, region)

The preceding statement produces the following output.


REGION High Sales
-------------- ----------
East YES
Central YES
west NO

Copyright © 2003 Oracle Corporation


Previous Next All Rights Reserved. Home Book List Contents Index Master Index Feedback

3 of 3 9/2/2009 5:06 PM

Das könnte Ihnen auch gefallen