stddev_samp¶
This function is used to return the sample deviation of a specified column.
Syntax¶
stddev_samp(col)
Parameters¶
Parameter | Mandatory | Description |
---|---|---|
col | Yes | Columns with a data type of numeric. If the values are of any other type, NULL is returned. |
Return Values¶
The return value is of the DOUBLE type.
Example Code¶
Calculates the sample deviation of all offering inventories (items). An example command is as follows:
select stddev_samp(items) from warehouse;
The command output is as follows:
+------------+ | _c0 | +------------+ | 1.342355 | +------------+
When used with group by, it groups all offerings by warehouse (warehouseId) and returns the sample deviation of the offering inventory (items) in the same group. An example command is as follows:
select warehouseId, stddev_samp(items) from warehouse group by warehouseId;
The command output is as follows:
+------------+------------+ | warehouseId| _c1 | +------------+------------+ | city1 | 1.23124 | | city2 | 1.23344 | | city3 | 1.43425 | +------------+------------+