Have both an alias and a variable?

Hi!

Not sure what bothers you from what you wrote. Each query block will iterate the set of nodes and compute the sum as provided. That is, pt as sum(val(payment)) will be closely linked to a nodes context. That’s why they repeat. It’s an aggregation behavior. The aggregation docs explains this.

As I explained above, only if you have only one Node as parent. or using the aggregation block for this.

Btw you could make the payments block as “var” instead a query block. Seems to me you just need the sum of amount.

Actually the docs show the syntax for this.

Get started with Dgraph

  • aliasName : varName as ...

paymentsTotal : pt as sum(val(pt))

But I feel like something is missing. Because I didn’t understand what the issue is.

1 Like