-
Notifications
You must be signed in to change notification settings - Fork 115
Aggregates #39
Comments
Note also that SQLite supports distinct aggregates:
which will be useful for operations like |
“Query variables not in aggregate expressions will group the results and appear intact in the result.” Generate SQL with a The resulting rows (including all variables used in aggregate expressions) should themselves be distinct. We might need work to do this. The aggregate expressions should translate fairly neatly to SQL, modulo any lurking edge-case semantic differences in comparison:
|
I believe that queries featuring aggregates must, in the general case, be produced with a subquery. That's because the aggregates are considered to apply to a basis set, the elements of which are unique across the projected and So
should result in
The alternative is that the aggregate function is called for non-distinct rows — non-distinct with or without the influence of It's a little perverse — after all, |
N.B., type conversion plays in here. For instance, if I query I don't think we can simply extract type tags alongside the maxed value: SQLite doesn't guarantee which row from the group will contribute. Instead, this will require schema-aware projection. Fortunately, that's already in place for ordinary queries. |
Fixed in b2a1af3. |
Implement support for aggregates in projection, starting with
max
.Aggregation implies grouping, so we will also need to support
:with
and be careful to deliberately hit the number-of-heads bug.The text was updated successfully, but these errors were encountered: