【问题标题】:Merging the result Two queries in Cosmosdb合并结果 Cosmosdb 中的两个查询
【发布时间】:2021-10-16 02:23:46
【问题描述】:
SELECT 
count(c.Transaction_Id) as Legacy FROM c where c.OverallStatus = 'COMPLETED' and c.KeyData2 like 'WLS_%'
and contains (c.Created_Date, '2021-08-11') and c.Transaction_Set_Code = '210'
SELECT 
count(c.Transaction_Id) as NonLegacy FROM c where c.OverallStatus = 'COMPLETED' and c.KeyData2 not like 'WLS_%'
and contains (c.Created_Date, '2021-08-11') and c.Transaction_Set_Code = '210'

必答:

[
    {
        "Legacy": 18753,
        "NonLegacy": 121862
    }
]

【问题讨论】:

  • 我不太确定你的问题是什么。您提供了两个查询,每个查询都生成 JSON 中的一个元素。你的具体问题是什么?请注意,您能够“组合”这些查询的唯一方法是执行某种类型的相关查询(尽管我没有针对您的特定情况尝试过 - 只是供您考虑)。
  • 我想将两个不同的查询合并为一个,因为我想在两个不同的条件下进行两次计数
  • 请编辑您的问题以包含您尝试过的内容以及示例输入数据。

标签: azure azure-cosmosdb azure-cosmosdb-sqlapi


【解决方案1】:
Select t.cnt , t.keyd from (
  SELECT count(1) as cnt, c.keydata2 as keyd 
  FROM c 
  where c.OverallStatus = 'COMPLETED' 
  and contains (c.Created_Date, '2021-08-11')
  and c.Transaction_Set_Code = '210'
  group by c.KeyData2)
t
 where t.keyd like 'wls_%' or t.keyd not like 'wls_%'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 2016-10-27
    • 2012-11-14
    • 2022-06-16
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多