Clear::SQL::Query::Aggregate
Instance methods
agg(field, x : X.class) forall X
Call an custom aggregation function, like MEDIAN or other:
query.agg("MEDIAN(age)", Int64)
COUNT, MIN, MAX, SUM and AVG are already conveniently mapped.
This return only one row, and should not be used with group_by (prefer pluck or fetch)
count(type : X.class = Int64) forall X
Use SQL COUNT over your query, and return this number as a Int64
as count return always a scalar, the usage of COUNT(*) OVER GROUP BY can be done by
using pluck or select
sum(field) : Float64
SUM through a field and return a Float64
This function is not safe injection-wise, so beware !.