# F131-01: WHERE, GROUP BY, and HAVING clauses supported in queries with grouped views

statement ok
CREATE TABLE TABLE_F131_01_01_01 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_01 AS SELECT A FROM TABLE_F131_01_01_01 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_01

statement ok
CREATE TABLE TABLE_F131_01_01_02 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_02 AS SELECT A FROM TABLE_F131_01_01_02 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_02 GROUP BY A

statement ok
CREATE TABLE TABLE_F131_01_01_03 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_03 AS SELECT A FROM TABLE_F131_01_01_03 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_03 GROUP BY A HAVING A = 2

statement ok
CREATE TABLE TABLE_F131_01_01_04 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_04 AS SELECT A FROM TABLE_F131_01_01_04 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_04 WHERE A = 1

statement ok
CREATE TABLE TABLE_F131_01_01_05 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_05 AS SELECT A FROM TABLE_F131_01_01_05 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_05 WHERE A = 1 GROUP BY A

statement ok
CREATE TABLE TABLE_F131_01_01_06 ( ID INT PRIMARY KEY, A INTEGER );

statement ok
CREATE VIEW VIEW_F131_01_01_06 AS SELECT A FROM TABLE_F131_01_01_06 GROUP BY A;

query I
SELECT A FROM VIEW_F131_01_01_06 WHERE A = 1 GROUP BY A HAVING A = 2
