Skip to main content

SKEW,SKEW_POP,SKEWNESS

Description​

Returns the skewness of the expr expression. The forumula used for this function is 3-th centrol moment / ((variance)^{1.5}), when variance is zero, SKEWNESS will return NULL.

Related Commands

kurt

Alias​

  • SKEW
  • SKEW_POP

Syntax​

SKEWNESS(<col>)

Parameters​

ParameterDescription
<col>The column to be calculated skewness

Return Value​

Returns the skewness of the expr expression, which is a Double type.

Examples​

CREATE TABLE statistic_test(
tag int,
val1 double not null,
val2 double null
) DISTRIBUTED BY HASH(tag)
PROPERTIES (
"replication_num"="1"
);

INSERT INTO statistic_test VALUES
(1, -10, -10),
(2, -20, NULL),
(3, 100, NULL),
(4, 100, NULL),
(5, 1000,1000);

-- NULL is ignored
SELECT
skew(val1),
skew(val2)
FROM statistic_test;
+--------------------+------------+
| skew(val1) | skew(val2) |
+--------------------+------------+
| 1.4337199628825619 | 0 |
+--------------------+------------+
-- Each group just has one row, result is NULL
SELECT
skew(val1),
skew(val2)
FROM statistic_test
GROUP BY tag;
+------------+------------+
| skew(val1) | skew(val2) |
+------------+------------+
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
+------------+------------+