I want to query and calculate the cumulative sum of a certain predicate,for example, I want to obtain the age and。
{
result(func: type(Person)){
age
}
}
I want to query and calculate the cumulative sum of a certain predicate,for example, I want to obtain the age and。
{
result(func: type(Person)){
age
}
}
@lock Check out this part of docs: Aggregation - Query language
And section Sum and Avg
I have tried sum, but this can only calculate the value of count()
eg:
{
result(func: type(Person)){
v as count(age)
}
me(){
sum(val(v))
}
}
You can sum without using count()
:
{
var(func: type(Person)){
v as age
}
x(){
sum(val(v))
}
}
Thank you very much. I found that the field type I used earlier was incorrect