slick-pg
slick-pg copied to clipboard
aggregate results of windowing functions
I need to take the min of the max in each group, e.g.:
import com.github.tminglei.slickpg.ExPostgresProfile.api._
import com.github.tminglei.slickpg.agg.PgAggFuncSupport.GeneralAggFunctions._
...
Table.map{ q =>
(
max(q.col).over.partitionBy(q.id).sortBy(q.col),
q.id
)
}
.groupBy{_ => true}
.map {
case (_, query) =>
query.map(_._1).min
}
bit it attempts to compose the window function inside the aggregate, which is not allowed and yields:
The future returned an exception of type: org.postgresql.util.PSQLException, with message: ERROR: aggregate function calls cannot contain window function calls
Can it be supported such that it does a subquery instead?
@evbo not easy, didn't find a good way out yet. :-(