Open grosch opened 4 years ago
Some initial thoughts:
final class BarCTE: ModelCTE {
@Aggregate(.count, \.$id)
var count: Int
@Aggregate(.max, \.$age)
var maxAge: Int?
}
Foo.query(on: db)
.join(BarCTE.self, on: \Foo.$id == \Bar.$foo.$id) {
$0.group(by: \.$country).group(by: \.$city)
}
.filter(BarCTE.self, \.$name == ...)
.all()
Depends on #206 being implemented first.
https://www.sqlservertutorial.net/sql-server-basics/sql-server-cte/
As an example, this is something I frequently do: