 Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » SQL functions (P-Z)

### STDDEV_SAMP function [Aggregate]

Computes the standard deviation of a sample consisting of a numeric-expression, as a DOUBLE.

###### Syntax 1
`STDDEV_SAMP( numeric-expression )`
###### Syntax 2
`STDDEV_SAMP( numeric-expression ) OVER ( window-spec )`
`window-spec : see Syntax 2 instructions in the Remarks section below`
###### Parameters
• numeric-expression   The expression whose sample-based standard deviation is calculated over a set of rows. The expression is commonly a column name.

DOUBLE

###### Remarks

This function converts its argument to DOUBLE, and performs the computation in double-precision floating point.

The standard deviation (s) is computed according to the following formula, which assumes a normal distribution:

s = [ (1/( N - 1 )) * SUM( xI - mean( x ) )2 ]½

This standard deviation does not include rows where numeric-expression is NULL. It returns NULL for a group containing either 0 or 1 rows.

Syntax 2 represents usage as a window function in a SELECT statement. As such, elements of window-spec can be specified either in the function syntax (inline), or in conjunction with a WINDOW clause in the SELECT statement. See the window-spec definition provided in WINDOW clause.

 ```SELECT YEAR( ShipDate ) AS Year, QUARTER( ShipDate ) AS Quarter, AVG( Quantity ) AS Average, STDDEV_SAMP( quantity ) AS Variance FROM SalesOrderItems GROUP BY Year, Quarter ORDER BY Year, Quarter;```