【问题标题】:how to group historical data in cumulocity cep query如何在 cumulocity cep 查询中对历史数据进行分组
【发布时间】:2018-04-19 19:29:56
【问题描述】:

我必须每天对上周的数据进行分组。我能够每 10 秒检索一次历史数据,但无法按日期分组

insert into AllMeasurementsOfWeek 
select findAllMeasurementByFragmentTypeAndSourceAndTimeBetween('Avg_Load','764697',(current_timestamp().minus(7 day)).toDate(),current_timestamp().toDate()) as m,current_timestamp().toDate() as time
from pattern[every timer:interval(10 sec)];


@Name("Occupancy")
@Resilient 
select  * from AllMeasurementsOfDay ;

以上代码将输出如下响应

{
  "m": [
    {
      "time": "2018-04-14T17:03:14.000+02:00",
      "id": "17345353",
      "source": "764697",
      "type": "Avg_Load",
      "Average_Load": {
        "loading_time": {
          "unit": "min",
          "value": 25
        }
      }
    },
    {
      "time": "2018-04-15T17:03:14.000+02:00",
      "id": "17345194",
      "source": "764697",
      "type": "Avg_Load",
      "Avg_Load": {
        "loading_time": {
          "unit": "min",
          "value": 25
        }
      }
    },
    {
      "time": "2018-04-15T17:03:14.000+02:00",
      "id": "17345194",
      "source": "764697",
      "type": "Avg_Load",
      "Avg_Load": {
        "loading_time": {
          "unit": "min",
          "value": 25
        }
      }
    }
]

我应该如何访问上述回复和按日期分组?

【问题讨论】:

    标签: complex-event-processing esper cumulocity


    【解决方案1】:

    你为什么不直接查询你想要的那一天呢?所以做 7 个查询(每天一个)。

    否则,每当您对具有日期范围的 API 进行查询时,它将按日期排序。因此,您也可以只添加一个小表达式(如 javascript)将其拆分为 7 天。应该很简单,因为响应已经按日期排序。

    【讨论】:

      猜你喜欢
      • 2021-05-02
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多