如何将一张表从分钟频聚合为日频?

例如下图,有几百列,对每列的聚合逻辑都一样,手写select max(000001), max(0000002)....from xxx group by date 效率太低。

attachments-2022-09-DDynRK4K6336af2545dc8.png

请先 登录 后评论

1 个回答

Boye

用元编程的方式可实现,示例如下:

t=table(2015.01.05 as date,2015.01.05T09:30:00 as datetime,1.0 as `000001,2.0 as `000002,3.0 as `000003)
sql(select =sqlCol(t.colNames()[2:],max),from =t,groupBy=sqlCol(`date)).eval()

执行后,输出如下所示:

date	000001	000002	000003
2015.01.05	1	2	3

请先 登录 后评论
  • 1 关注
  • 0 收藏,860 浏览
  • Shepherd 提出于 2022-09-30 16:54

相似问题