Documentation
¶
Overview ¶
Package pgagg provides PostgreSQL-specific aggregate functions for sorm projections. Using them on another dialect is a build error returned when the query executes — never silently wrong SQL.
rows, err := sorm.Project[stat](
sorm.From[models.User](db).GroupBy(u.Country),
sorm.Field(u.Country),
sorm.As(pgagg.StringAgg[models.User](u.Name, ", "), "names"),
sorm.As(pgagg.PercentileCont[models.User](0.5, u.Age), "median_age"),
).All(ctx)
Index ¶
- func ArrayAgg[E any](c sorm.AnyCol) sorm.AggExpr[E, string]
- func BitAnd[E any](c sorm.AnyCol) sorm.AggExpr[E, int64]
- func BitOr[E any](c sorm.AnyCol) sorm.AggExpr[E, int64]
- func BoolAnd[E any](c sorm.AnyCol) sorm.AggExpr[E, bool]
- func BoolOr[E any](c sorm.AnyCol) sorm.AggExpr[E, bool]
- func Corr[E any](y, x sorm.AnyCol) sorm.AggExpr[E, float64]
- func CovarPop[E any](y, x sorm.AnyCol) sorm.AggExpr[E, float64]
- func CovarSamp[E any](y, x sorm.AnyCol) sorm.AggExpr[E, float64]
- func JSONBAgg[E any](c sorm.AnyCol) sorm.AggExpr[E, string]
- func JSONBObjectAgg[E any](k, v sorm.AnyCol) sorm.AggExpr[E, string]
- func Mode[E any](orderBy sorm.AnyCol) sorm.AggExpr[E, string]
- func PercentileCont[E any](fraction float64, orderBy sorm.AnyCol) sorm.AggExpr[E, float64]
- func PercentileDisc[E any](fraction float64, orderBy sorm.AnyCol) sorm.AggExpr[E, float64]
- func StdDev[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
- func StdDevPop[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
- func StdDevSamp[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
- func StringAgg[E any](c sorm.AnyCol, sep string) sorm.AggExpr[E, string]
- func VarPop[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
- func VarSamp[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
- func Variance[E any](c sorm.AnyCol) sorm.AggExpr[E, float64]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONBObjectAgg ¶
JSONBObjectAgg — jsonb_object_agg(k, v).
func PercentileCont ¶
PercentileCont — percentile_cont(fraction) WITHIN GROUP (ORDER BY col): continuous percentile (0.5 = median, interpolated).
func PercentileDisc ¶
PercentileDisc — percentile_disc(fraction) WITHIN GROUP (ORDER BY col): discrete percentile (an actual value from the set).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.