SQL Impala手动产生标准偏差
我有这样的表:
值 | 频率 | grpng |
---|---|---|
2 | 1 | Cat1 |
3 | 2 | Cat1 |
4 | 1 | Cat1 |
2 | 2 | Cat2 |
1 | Cat2 1 | Cat2 |
5 | 2 | Cat2 |
我想生成每组标准偏差(sds sd)(cat1,cat2) 不是具有窗口函数,而是通过将WRT分组到GRPNG变量。 我看到两个选项:
- 使用频率扩展值,然后使用标准SQL SD DEV函数。
- 直接分组,并在可能的情况下手动获取SD DEV。
您可以建议解决方案吗?对于第一个选项,我找不到在Impala中扩展的功能。
我期望的结果是:
SDDEV | GRPNG |
---|---|
0.70710678118655 | CAT1 |
1.6733200530682 | CAT2 |
I have a table like this:
values | frequencies | grpng |
---|---|---|
2 | 1 | cat1 |
3 | 2 | cat1 |
4 | 1 | cat1 |
2 | 2 | cat2 |
1 | 1 | cat2 |
5 | 2 | cat2 |
I want to generate the standard deviation (population sd) per group (cat1, cat2)
not with a window function but by grouping wrt to the grpng variable.
I see two options:
- Expand the values using the frequencies and then use the standard sql sd dev function.
- Directly group and get the sd dev manually if possible.
Can you suggest a solution? For the first option I am not able to find a function to expand in Impala.
My desired outcome is:
sddev | grpng |
---|---|
0.70710678118655 | cat1 |
1.6733200530682 | cat2 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论