func Sum(field string) AggregateFunc {
	return func(s *sql.Selector, check func(string) bool) string {
		if !check(field) {
			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
			return ""
		}
		return sql.Sum(s.C(field))
	}
}
Sum applies the "sum" aggregation function on the given field of each group.
package models
import (
	"errors"
	"fmt"
	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)
type (
	Op         = ent.Op
	Hook       = ent.Hook
	Value      = ent.Value
	Query      = ent.Query
	Policy     = ent.Policy
	Mutator    = ent.Mutator
	Mutation   = ent.Mutation
	MutateFunc = ent.MutateFunc
)
type OrderFunc func(*sql.Selector, func(string) bool)
func Asc(fields ...string) OrderFunc {
	return func(s *sql.Selector, check func(string) bool) {
		for _, f := range fields {
			if check(f) {
				s.OrderBy(sql.Asc(f))
			} else {
				s.AddError(&ValidationError{Name: f, err: fmt.Errorf("invalid field %q for ordering", f)})
			}
		}
	}
}
func Desc(fields ...string) OrderFunc {
	return func(s *sql.Selector, check func(string) bool) {
		for _, f := range fields {
			if check(f) {
				s.OrderBy(sql.Desc(f))
			} else {
				s.AddError(&ValidationError{Name: f, err: fmt.Errorf("invalid field %q for ordering", f)})
			}
		}
	}
}
type AggregateFunc func(*sql.Selector, func(string) bool) string
func As(fn AggregateFunc, end string) AggregateFunc {
	return func(s *sql.Selector, check func(string) bool) string {
		return sql.As(fn(s, check), end)
	}
}
func Count() AggregateFunc {
	return func(s *sql.Selector, _ func(string) bool) string {
		return sql.Count("*")
	}
}
func Max(field string) AggregateFunc {
	return func(s *sql.Selector, check func(string) bool) string {
		if !check(field) {
			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
			return ""
		}
		return sql.Max(s.C(field))
	}
}
func Mean(field string) AggregateFunc {
	return func(s *sql.Selector, check func(string) bool) string {
		if !check(field) {
			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
			return ""
		}
		return sql.Avg(s.C(field))
	}
}
func Min(field string) AggregateFunc {
	return func(s *sql.Selector, check func(string) bool) string {
		if !check(field) {
			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
			return ""
		}
		return sql.Min(s.C(field))
	}
}