Skip Headers

Oracle® OLAP DML Reference
10g Release 1 (10.1)

Part Number B10339-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

STDDEV

The STDDEV function calculates the standard deviation of the values of an expression.

Return Value

DECIMAL

Syntax

STDDEV(expression [[STATUS] dimensions])

Arguments

expression

The numeric expression whose standard deviation is to be calculated.

STATUS

Can be specified when one or more of the dimensions of the result of the function are not dimensions of the expression. (See the description of the dimensions argumentw.) When you specify the STATUS keyword when this is not the case, then an error results.

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

dimensions

The dimensions of the result. By default, STDDEV returns a single value. When you indicate one or more dimensions for the results, STDDEV calculates a standard deviation along the specified dimension(s) and returns an array of values. Each dimension must be either a dimension of 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 enables you to choose the relation to use when there is more than one.

Notes


NA Values

STDDEV is affected by the NASKIP option. When NASKIP is set to YES (the default), STDDEV ignores NA values and returns the standard deviation of the values that are not NA. When NASKIP is set to NO, STDDEV returns NA when any value in the calculation is NA. When all data values for a calculation are NA, STDDEV returns NA for either setting of NASKIP.


Calculating over a Time Dimension

When expression is dimensioned by a dimension of type DAY, WEEK, MONTH, QUARTER, or YEAR, you can specify any other dimensions of type DAY, WEEK, MONTH, QUARTER, or YEAR as a related dimension. Oracle OLAP uses the implicit relation between the dimensions. To control the mapping of one dimensions of type DAY, WEEK, MONTH, QUARTER, or YEAR to another (for example, from weeks to months), you can define an explicit relation between the two dimensions and specify the name of the relation as the dimension argument to the STDDEV function.

For each time period in the related dimensions of type DAY, WEEK, MONTH, QUARTER, and YEAR, Oracle OLAP calculates the standard deviation of the data values of 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. To control the way in which data is aggregated or allocated between the periods of two dimensions of type DAY, WEEK, MONTH, QUARTER, and YEAR, you can use the TCONVERT function.


The STATUS Keyword

When one or more of the dimensions of the result of the function are not dimensions of the expression, Oracle OLAP creates a temporary variable to use while processing the function. When you specify the STATUS keyword, then 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 successfully execute the function. When the dimensions of the 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 STDDEV 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.

Examples

Example 23-1 Calculating the Standard Deviation of Monthly Sales

This example calculates the average number of tents sold during the first three months of 1996, along with the standard deviation from that average.

LIMIT district TO ALL
LIMIT month TO 'Jan96' TO 'Mar96'
LIMIT product TO 'Tents'
REPORT HEADING 'Average' AVERAGE(units month) -
   HEADING 'Stddev' STDDEV(JAN96              262.33      49.32
FEB96              247.83      57.37
MAR96  units month)

These statements produce the following output.

MONTH           Average     Stddev
-------------- ---------- ----------
Jan96              262.33      49.32
Feb96              247.83      57.37
Mar96              320.50      68.17