0

我在计算每个区域的用户时遇到问题,每个用户都会将他们的语言环境发送到服务器。有人可以帮助我实现这一目标,谢谢。输出流分析应该是这样的:

{
   "sessionId": "sessionId1", -->group by sessionId
   "data": {
        "North America": 0,
        "South America": 0,
        "Europe": 0,
        "Russia": 1,
        "Africa": 2,
        "India": 0,
        "China": 2,
        "Oceania": 0, 
   }
},
{
   "sessionId": "sessionId2", -->group by sessionId
   "data": {
        "North America": 0,
        "South America": 0,
        "Europe": 0,
        "Russia": 0,
        "Africa": 1,
        "India": 0,
        "China": 0,
        "Oceania": 0, 
   }
}

输入数据:

[{"sessionId":"Session1","deviceId":"deviceTest1","locale":"Russia"},{"sessionId":"Session1","deviceId":"deviceTest2","locale":"China"},{"sessionId":"Session1","deviceId":"deviceTest3","locale":"China"},{"sessionId":"Session1","deviceId":"deviceTest4","locale":"Africa"},{"sessionId":"Session1","deviceId":"deviceTest5","locale":"Africa"},{"sessionId":"Session2","deviceId":"deviceTest6","locale":"Africa"}]
4

1 回答 1

0

我试过薮 SQL 查询,但无法达到您的要求。我认为这是不可能的,因为您需要 group by sessionId,但是没有聚合函数可以获取这种格式。

"data": {
        "North America": 0,
        "South America": 0,
        "Europe": 0,
        "Russia": 0,
        "Africa": 1,
        "India": 0,
        "China": 0,
        "Oceania": 0, 
   }
于 2020-11-13T08:08:35.690 回答