azure - 合并结果 Cosmosdb 中的两个查询
问题描述
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
}
]
解决方案
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_%'
推荐阅读
- c# - 按名称搜索的 Twitter API 请求趋势(按名称搜索)
- python - 如何在 Django 中修改表单模型数据
- assembly - 使用masm编译器将结构嵌套到汇编文件中
- go - 匿名结构无法使用复合文字编译
- javascript - vue.runtime.esm.js?2b0e:1888 TypeError: vue_amap__WEBPACK_IMPORTED_MODULE_0___default.a.service 不是函数
- python - 如何使用 jinja 过滤和显示烧瓶 sqlalchemy 一对多关系数据
- asp.net - ASP.NET 如何将值从表单传递到另一个页面
- c++ - cpp线程连接如果两个线程相互依赖应该使用连接导致死锁
- web-applications - 在 rust 中使用 warp 服务静态文件
- java - 使用 String.split() 如何根据正则表达式拆分字符串,不包括某个字符串