STD_DEV

‌The STD_DEV function returns the standard deviation of a set of numbers.

Syntax

stddev(VALUE)

Arguments

VALUE: An expression that evaluates to a numeric.

Returns

Returns a value of any built-in numeric data type.

Notes

In Athena output, STD_DEV data can be BIGINT or NUMBER type. In Upsolver output, STD_DEV data can be NUMBER type only.

Example

Data

[
   {
      "serverIp":"10.0.0.1",
      "time":1628894700000,
      "cpuUsage":52.3
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894760000,
      "cpuUsage":2.4
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894820000,
      "cpuUsage":99.3
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894880000,
      "cpuUsage":99.6
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894940000,
      "cpuUsage":12.3
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628895000000,
      "cpuUsage":55
   },
   {
      "serverIp":"10.0.0.2",
      "time":1628894700000,
      "cpuUsage":2.3
   },
   {
      "serverIp":"10.0.0.2",
      "time":1628894760000
   },
   {
      "serverIp":"10.0.0.2",
      "time":1628894820000,
      "cpuUsage":9.3
   },
   {
      "serverIp":"10.0.0.2",
      "time":1628894880000,
      "cpuUsage":9.6
   },
   {
      "serverIp":"10.0.0.2",
      "time":1628894940000,
      "cpuUsage":2.3
   }
]

Query

Find the standard deviation of cpu usage of each server:

SELECT
   data.serverIp AS serverip:STRING,
   STD_DEV(data.cpuUsage) AS std_dev_data_cpuusage:NUMBER 
FROM
   "TIME_SERIES_DATA_w_NULL" 
GROUP BY
   data.serverIp

Results:

{
   "std_dev_data_cpuusage":4,
   "serverip":"10.0.0.2"
}{
   "std_dev_data_cpuusage":41,
   "serverip":"10.0.0.1"
}

STD_DEV_EACH

Dialog

Last updated