Skip to content

iotdb1.3.1下如何写按每小时刻度求和聚合查询 #17029

@waittingsummer

Description

@waittingsummer

查询过去1年的数据,原始数据是写在整点的每小时1个点的数据
1天的原始数据如下


IoTDB> select C  from root.A.B
> where time >= 2025-01-01T00:00:00.000
> and time < 2025-01-02T00:00:00.000
+-----------------------------+-------------------------+
|                         Time|root.A.B.C|
+-----------------------------+-------------------------+
|2025-01-01T00:00:00.000+08:00|                   1324.0|
|2025-01-01T01:00:00.000+08:00|                   1390.0|
|2025-01-01T02:00:00.000+08:00|                    916.0|
|2025-01-01T03:00:00.000+08:00|                   1436.0|
|2025-01-01T04:00:00.000+08:00|                   2714.0|
|2025-01-01T05:00:00.000+08:00|                   2172.0|
|2025-01-01T06:00:00.000+08:00|                   1932.0|
|2025-01-01T07:00:00.000+08:00|                   9294.0|
|2025-01-01T08:00:00.000+08:00|                  11974.0|
|2025-01-01T09:00:00.000+08:00|                  10364.0|
|2025-01-01T10:00:00.000+08:00|                   6018.0|
|2025-01-01T11:00:00.000+08:00|                   5322.0|
|2025-01-01T12:00:00.000+08:00|                   3600.0|
|2025-01-01T13:00:00.000+08:00|                   1852.0|
|2025-01-01T14:00:00.000+08:00|                   1312.0|
|2025-01-01T15:00:00.000+08:00|                    692.0|
|2025-01-01T16:00:00.000+08:00|                   1484.0|
|2025-01-01T17:00:00.000+08:00|                   4562.0|
|2025-01-01T18:00:00.000+08:00|                   3532.0|
|2025-01-01T19:00:00.000+08:00|                   3540.0|
|2025-01-01T20:00:00.000+08:00|                   2586.0|
|2025-01-01T21:00:00.000+08:00|                   6798.0|
|2025-01-01T22:00:00.000+08:00|                  11088.0|
|2025-01-01T23:00:00.000+08:00|                   6404.0|
+-----------------------------+-------------------------+
Total line number = 24
It costs 0.148s

然后全年数据按照0-24小时刻度分组求和
全年0点-1点的数据累计在0点刻度
全年1点-2点的数据累计在1点刻度
以此类推
这样的sql查询要怎么写呢?好像实现不了
目前使用的工具主要是start_cli和dbeaver

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions