Hitachi

Hitachi Advanced Database SQL Reference


7.22.8 STDDEV_SAMP

STDDEV_SAMP determines the standard deviation of a sample.

Organization of this subsection

(1) Specification format

general-set-function-STDDEV_SAMP ::= STDDEV_SAMP(value-expression)

(2) Explanation of specification format

value-expression:

Specifies the input values, in the form of a value expression, that make up the sample whose standard deviation is to be determined. For details about value expressions, see 7.20 Value expression.

(3) Rules

  1. Null values are not included in the calculation.

  2. In the following cases, the execution result will be a null value.

    • If the number of input rows is 0 or 1

    • If the values to be calculated are all null values

  3. The execution result of the general set function STDDEV_SAMP will be equal to the square root of the general set function VAR_SAMP.

  4. The following table shows the data type that can be specified in the value expression and the data type of the execution result of the general set function STDDEV_SAMP.

    Table 7‒21: Data type that can be specified in the value expression and data type of the execution result of the general set function STDDEV_SAMP

    No.

    Data type that can be specified in the value expression

    Data type of the execution result of general set function STDDEV_SAMP

    1

    INTEGER

    DOUBLE PRECISION

    2

    SMALLINT

    3

    DECIMAL(m,n)

    4

    DOUBLE PRECISION

(4) Example

Example

Using the data in the salary table (SALARYLIST), this example determines the standard deviation of a sample of employee salaries (SALARY).

SELECT STDDEV_SAMP("SALARY") AS "STDDEV_SAMP"
    FROM "SALARYLIST"

Example of execution results

[Figure]