数据湖探索 DLI-stddev_samp:示例代码

时间:2025-02-12 14:55:48

示例代码

  • 计算所有商品库存(items)的样本偏差。命令示例如下:
    select stddev_samp(items) from warehouse; 

    返回结果如下:

    +------------+| _c0        |+------------+| 1.342355   |+------------+
  • 与group by配合使用,对所有商品按照仓库(warehourseId)进行分组,并计算同组商品库存(items)的样本偏差。命令示例如下:
    select warehourseId, stddev_samp(items) from warehourse group by warehourseId; 

    返回结果如下:

    +------------+------------+| warehouseId| _c1        |+------------+------------+| city1    | 1.23124   || city2    | 1.23344   || city3    | 1.43425   |+------------+------------+
support.huaweicloud.com/sqlref-spark-dli/dli_spark_stddev_samp.html