Very much like in Scala collections:
stmts.filter(_.orgid === orgId)
.innerJoin(rctns).on(_.id === _.stmtId)
.groupBy(_._1.id)
.sortBy{ case (s_id,group) =>
group.map(_._1.time).max + interval(
group.map(_._2.stmtId).length,
"DAY"
)
}
The .max
is a hack because we currently do not support .head
, which you would have to use in Scala collections. Be aware, that interval
does not come with Slick and you will have to define it yourself using the SimpleExpression
construct, see http://slick.typesafe.com/doc/2.0.2/userdefined.html#scala-database-functions.
Notice that in the past we had more bugs with group by in Slick than with other operations. SQL pulls a lot of type-tricks (identifiers changing type between collections and scalar values, etc.), which are tricky to get right in a mapping to Scala semantics. The things we know about are fixed now. If you experience a case where invalid SQL is generated, please report a bug that allows us to reproduce the problem.