statement ok
CREATE TABLE test (id int primary key, x int, y int);

statement ok
INSERT INTO test VALUES (0, 1, 2), (1, 2, 2), (2, 11, 22)

query II
select y as b, sum(x) as sum from test group by b having b = 2
----
2 3

query II
select count(x) as a, y as b from test group by b having a > 1
----
2 2

query II
select count(x) as a, y + 1 as b from test group by b having b + 1 = 24;
----
1 23

query II
select x from test group by x having max(y) = 22
----
11

# FIXME
# query II
# select y + 1 as i from test group by y + 1 having count(x) > 1 and y + 1 = 3 or y + 1 = 23 order by i;
# ----
# 3
# 23

statement error
select count(x) from test group by count(x)