statement ok
create table t (id int primary key, v1 int, v2 int)

statement ok
insert into t values (0,1,1), (1,2,1), (2,3,2), (3,4,2), (4,5,3)

statement error
select v2 + 1, v1 from t group by v2 + 1

statement error
select v2 + 1 as a, v1 as b from t group by a

statement error
select v2, v2 + 1, sum(v1) from t group by v2 + 1

statement error
select v2 + 2 + count(*) from t group by v2 + 1

statement error
select v2 + count(*) from t group by v2 order by v1;

query II rowsort
select v2 + 1, sum(v1) from t group by v2 + 1
----
2	3
3	7
4	5

query III rowsort
select sum(v1), v2 + 1 as a, count(*) from t group by a
----
3	2	2
5	4	1
7	3	2

query III rowsort
select v2, v2 + 1, sum(v1) from t group by v2 + 1, v2
----
1	2	3
2	3	7
3	4	5

query III rowsort
select v2, v2 + 1, sum(v1) from t group by v2 + 1, v2 order by v2
----
1	2	3
2	3	7
3	4	5

# TODO
# query I rowsort
# select v1 + 1 + count(*) from t group by v1 + 1
# ----
# 3
# 4
# 5
# 6
# 7

statement ok
drop table t