我有两个或多个具有相同 Id 的事件,例如会话,但具有不同的属性值,我应该查询按 id 分组的所有事件并计算两个时间戳之间的差异。
事件示例
活动一:
{ 类型:'开始', 编号:1 ... }
活动二:
{ 类型:'结束', 编号:1 ... }
伪查询:
选择(结束.timrstamp-开始.时间戳)/1000 按 ID 分组
我认为一种可能的解决方案是
SELECT average(duration) FROM (
SELECT (
(filter(latest(timestamp), where transitionName = 'STARTED') -
filter(latest(timestamp), where transitionName = 'CREATED'))
) AS 'duration'
FROM table
FACET id AS uniqueId
SINCE last hour