query queryUserStatusAggregation($eventFilter: string, $startTime: string, $endTime: string) {
filteredStatuses as var(func: type(UserStatus))
@cascade(UserStatus.event)
@filter(between(UserStatus.time, $startTime, $endTime))
{
UserStatus.event @filter(uid($eventFilter)) {
uid
}
}
queryUserUserStatusAggregation(func: uid(filteredStatuses))
@groupby(key: UserStatus.type)
{
count(uid)
}
}
Response
{
"data": {
"queryUserStatusAggregation": [
{
"@groupby": [
{
"key": "UNREGISTERED",
"count": 2
},
{
"key": "REGISTERED",
"count": 3
}
]
}
]
}
}
The above query works fine but I want to groupby multiple fields
@groupby(key: [UserStatus.type, UserStatus.time, User.id])
Also, I’m curious about
- How can I extract the Date from the
DateTimefield just like we do in SQL usingExtractfunction and then use it inside the groupby - How can we convert the timezone at runtime while querying the data.