Getting sum of values grouped by predicate

BTW, You don’t need even @groupby

{
   q(func:has(isPaymentType)) @normalize
  {
    uid
    Payment.Type : Payment.Type
    isPaymentType : isPaymentType
    ~paymentType {
    AM as amount
    }
    Total : sum(val(AM))
  }
}