azure - cosmos无法删除重复的uuid
问题描述
你好,我发这个小消息,知道是否可以删除
模型如下:
创建日志数据
{
"publisherID": "",
"managerID": "",
"mediaID": "",
"type": "",
"ip": "",
"userAgent": "",
"playerRes": "",
"title": "",
"playerName": "",
"videoTimeCode": 0,
"geo": {
"country": "",
"region": "",
"city": "",
"ll": []
},
"date": "",
"uuid": "",
"id": ""
}
选择所有日志数据:SELECT * FROM a
[
{
"publisherID": "{ID}",
"mediaID": "{ID}",
"type": "Load",
"ip": "67.69.69.41",
"userAgent": "Mozilla/5.0 (Android 11; Mobile; rv:91.0) Gecko/91.0 Firefox/91.0",
"parentReferrer": "link.com",
"title": "title here",
"playerName": "page",
"videoTimeCode": 0,
"geo": {
"country": "CA",
"region": "Ontario",
"city": "Guelph",
"ll": [
43.5588,
-80.3004
]
}
}
]
[SQL-QUERY]: 01 - 不起作用,因为总是有重复的 uuid
- 我想要所有类型为进度的请求
type: 'Progress'
type
根据日期按分钟整理进度数据
SELECT COUNT(c.uuid) as total,
left(c.date,16) as time
FROM c
WHERE c.mediaID = '{ID}'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY c.uuid, left(c.date, 16)
[
{
"total": 9,
"time": "2021-09-03T14:07"
},
{
"total": 40,
"time": "2021-09-02T12:51"
},
{
"total": 51,
"time": "2021-09-02T12:50"
}
]
[SQL-QUERY]:02 - 宇宙错误!
语法错误,“DISTINCT”附近的语法不正确。
SELECT COUNT(DISTINCT c.uuid) as total, left(c.date,16) as time
FROM c
WHERE c.mediaID = 'ckpwphqbj10852aav7ib0713o8'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY c.uuid, left(c.date, 16)
我想删除重复的 uuid,然后按日期对唯一的 uuid 进行分组
解决方案
你在找这个吗?
计算distinct
uuid:
SELECT COUNT(distinct c.uuid) as total, left(c.date,16) as time
FROM c
WHERE c.postID = '155478'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY left(c.date, 16)
推荐阅读
- python - 当 __aenter__() 使用 'async with' 失败时会发生什么?
- jboss - 如何在 Wildfly 14 中禁用 JBOSS-LOCAL-USER SASL 机制
- c# - 使用 C# 在复杂的 JSON 数组中查找和打印重复项
- reactjs - 反应:功能中的陈旧状态但不是标记
- excel - Laravel Excel 导入,多表验证
- python - 从多个目录中的 txt 文件创建 dict
- javascript - 如何使用 HTML 和 javascript 在形状猜谜游戏中应用获胜策略
- javascript - 读取文件时出错:“await”操作数的类型必须是有效的承诺,或者不能包含可调用的“then”成员
- mongodb - 无法连接到 mongoDB 图集
- node.js - 如何解决这些承诺链?