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
Aliasβ
- SKEW
- SKEW_POP
Syntaxβ
SKEWNESS(<col>)
Parametersβ
Parameter | Description |
---|---|
<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 |
+------------+------------+