dolphindb - 在 DolphinDB 中计算分组百分比
问题描述
有没有一种方便的方法来计算 DolphinDB 中组中每个项目的百分比?
例如:
groupID x percentage
1 1 0.25
1 1 0.25
1 2 0.5
2 4 0.2
2 6 0.3
2 10 0.5
在 kdb 中,我可以用fby
. 我想知道在 DolphinDB 中是否有类似的方法。
解决方案
context by
在 dolphindb 中使用 SQL 扩展:
select groupID, x, x\sum(x) as percentage from t context by groupID
推荐阅读
- reactjs - Antd V4 表单列表 setFieldValue
- sql-server-2008 - 使用相关子查询与父查询的 sql 性能与通过获取最新记录的方法进行过度/分区
- python - 将字符串转换为 numpy 数组
- scala - 试图理解 apply 方法?
- go - 创建满足接口的结构
- c# - 有没有办法在没有原始源代码的情况下自动化 C# .Net 应用程序
- java - java android WebView进度对话框问题
- flutter - 如何在容器或卡片中获得颤动的项目或文本的编号列表?
- java - 在处理的python模式下使用Box2D时如何检测碰撞?
- javascript - 如何在比谷歌表格中的其他列短的列末尾找到值的最后一个单元格?