【发布时间】:2022-06-13 01:06:30
【问题描述】:
我正在寻找一些帮助来编写查询以查找 cosmos 中每个当前两个小时窗口的记录计数,而且我应该能够将所有结果与其他表结果联合
例如:-
TIme window count
10:00 AM to 12:00 AM 100
12:00AM TO 2 AM 200
2:00 AM to 4 AM 300
4:00 to 6 AM 400
我正在使用以下查询
SELECT count(1) as File_count
from a where a.file_model = "Log_Type"
and a.ingest_time>="2022-05-09T20:00:00" and c.ingest_time <= "2022-05-09T22:00:00"
union all
SELECT count(1) as WDL_Files_Processed_Count
from a where c.file_model = "Log_Type"
and a.ingest_time>="2022-05-09T20:00:00" and a.ingest_time <= "2022-05-09T22:00:00" and a.mapr_time!="" and contains(a.fileName,'SDK',true)
我知道在 cosmos 中没有 union all ,但这正是我在 cosmos 中所期待的。
Sample Data :-
ingest_time count
2022-05-09T22:00:00 10
2022-05-09T22:10:00 20
2022-05-09T22:30:00 40
2022-05-09T23:00:00 10
2022-05-09T23:20:00 45
2022-05-09T23:40:00 50
2022-05-09T24:00:00 100
【问题讨论】:
-
请编辑您的问题以显示您的数据架构(在您的情况下为图形模型,因为您使用的是 Graph API)。没有它,就没有办法知道如何开始。此外,包括您的查询以及具体问题。目前,您只提供了一些示例输出,没有输入数据,也没有显示任何工作。
-
完成,添加查询
-
好的,所以要明确一点:1) 这不是一个有效的 Cosmos DB 查询,我知道你说过但是......这意味着你没有尝试过任何事情? 2) 请确保添加正确的格式 - 我已经编辑了你的示例输出 - 这应该作为你遵循的一个很好的例子; 3) 您正在显示一个 SQL API 查询,但您将此标记为 Gremlin API 问题(非常不同)。你真的需要在你的问题和你的标签中都是具体的。仍然没有输入数据。
-
已添加示例数据。
标签: azure-cosmosdb