beanquery
beanquery copied to clipboard
ORDER BY clause with no target should work
trafficstars
This should work:
beancount> select account, sum(position) where currency = 'IRAUSD' group by account order by type;
ERROR: All non-aggregates must be covered by GROUP-BY clause in aggregate query.
I am not sure what the query would do if accepted.
BQL does not accept bare columns in aggregate queries. Not accepting bare columns in ORDER BY clause as well seems consistent with this choice. SQLite accepts bare columns in aggregate queries https://sqlite.org/lang_select.html#bare_columns_in_an_aggregate_query A rapid test shows that bare columns are accepted both in the targets list and in the ORDER BY clause. However, the returned value is undefined and the ORDER BY has no effect.