# F131-04: Subqueries with GROUP BY and HAVING clauses and grouped views

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

statement ok
CREATE TABLE TABLE_F131_04_01_012 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B < ( SELECT A FROM TABLE_F131_04_01_011 GROUP BY A ) FROM TABLE_F131_04_01_012

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

statement ok
CREATE TABLE TABLE_F131_04_01_022 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B < ( SELECT A FROM TABLE_F131_04_01_021 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_022

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

statement ok
CREATE TABLE TABLE_F131_04_01_032 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B <= ( SELECT A FROM TABLE_F131_04_01_031 GROUP BY A ) FROM TABLE_F131_04_01_032

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

statement ok
CREATE TABLE TABLE_F131_04_01_042 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B <= ( SELECT A FROM TABLE_F131_04_01_041 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_042

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

statement ok
CREATE TABLE TABLE_F131_04_01_052 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B <> ( SELECT A FROM TABLE_F131_04_01_051 GROUP BY A ) FROM TABLE_F131_04_01_052

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

statement ok
CREATE TABLE TABLE_F131_04_01_062 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B <> ( SELECT A FROM TABLE_F131_04_01_061 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_062

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

statement ok
CREATE TABLE TABLE_F131_04_01_072 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B = ( SELECT A FROM TABLE_F131_04_01_071 GROUP BY A ) FROM TABLE_F131_04_01_072

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

statement ok
CREATE TABLE TABLE_F131_04_01_082 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B = ( SELECT A FROM TABLE_F131_04_01_081 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_082

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

statement ok
CREATE TABLE TABLE_F131_04_01_092 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B > ( SELECT A FROM TABLE_F131_04_01_091 GROUP BY A ) FROM TABLE_F131_04_01_092

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

statement ok
CREATE TABLE TABLE_F131_04_01_102 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B > ( SELECT A FROM TABLE_F131_04_01_101 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_102

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

statement ok
CREATE TABLE TABLE_F131_04_01_112 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B >= ( SELECT A FROM TABLE_F131_04_01_111 GROUP BY A ) FROM TABLE_F131_04_01_112

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

statement ok
CREATE TABLE TABLE_F131_04_01_122 ( ID INT PRIMARY KEY, B INTEGER );

query B
SELECT B >= ( SELECT A FROM TABLE_F131_04_01_121 GROUP BY A HAVING A = 5 ) FROM TABLE_F131_04_01_122

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

statement ok
CREATE TABLE TABLE_F131_04_02_012 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_01 AS SELECT A FROM TABLE_F131_04_02_011 GROUP BY A;

query B
SELECT B < ( SELECT A FROM VIEW_F131_04_02_01 ) FROM TABLE_F131_04_02_012

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

statement ok
CREATE TABLE TABLE_F131_04_02_022 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_02 AS SELECT A FROM TABLE_F131_04_02_021 GROUP BY A;

query B
SELECT B <= ( SELECT A FROM VIEW_F131_04_02_02 ) FROM TABLE_F131_04_02_022

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

statement ok
CREATE TABLE TABLE_F131_04_02_032 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_03 AS SELECT A FROM TABLE_F131_04_02_031 GROUP BY A;

query B
SELECT B <> ( SELECT A FROM VIEW_F131_04_02_03 ) FROM TABLE_F131_04_02_032

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

statement ok
CREATE TABLE TABLE_F131_04_02_042 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_04 AS SELECT A FROM TABLE_F131_04_02_041 GROUP BY A;

query B
SELECT B = ( SELECT A FROM VIEW_F131_04_02_04 ) FROM TABLE_F131_04_02_042

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

statement ok
CREATE TABLE TABLE_F131_04_02_052 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_05 AS SELECT A FROM TABLE_F131_04_02_051 GROUP BY A;

query B
SELECT B > ( SELECT A FROM VIEW_F131_04_02_05 ) FROM TABLE_F131_04_02_052

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

statement ok
CREATE TABLE TABLE_F131_04_02_062 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_06 AS SELECT A FROM TABLE_F131_04_02_061 GROUP BY A;

query B
SELECT B >= ( SELECT A FROM VIEW_F131_04_02_06 ) FROM TABLE_F131_04_02_062

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

statement ok
CREATE TABLE TABLE_F131_04_02_072 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_07 AS SELECT A FROM TABLE_F131_04_02_071 GROUP BY A HAVING A = 5;

query B
SELECT B < ( SELECT A FROM VIEW_F131_04_02_07 ) FROM TABLE_F131_04_02_072

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

statement ok
CREATE TABLE TABLE_F131_04_02_082 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_08 AS SELECT A FROM TABLE_F131_04_02_081 GROUP BY A HAVING A = 5;

query B
SELECT B <= ( SELECT A FROM VIEW_F131_04_02_08 ) FROM TABLE_F131_04_02_082

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

statement ok
CREATE TABLE TABLE_F131_04_02_092 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_09 AS SELECT A FROM TABLE_F131_04_02_091 GROUP BY A HAVING A = 5;

query B
SELECT B <> ( SELECT A FROM VIEW_F131_04_02_09 ) FROM TABLE_F131_04_02_092

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

statement ok
CREATE TABLE TABLE_F131_04_02_102 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_10 AS SELECT A FROM TABLE_F131_04_02_101 GROUP BY A HAVING A = 5;

query B
SELECT B = ( SELECT A FROM VIEW_F131_04_02_10 ) FROM TABLE_F131_04_02_102

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

statement ok
CREATE TABLE TABLE_F131_04_02_112 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_11 AS SELECT A FROM TABLE_F131_04_02_111 GROUP BY A HAVING A = 5;

query B
SELECT B > ( SELECT A FROM VIEW_F131_04_02_11 ) FROM TABLE_F131_04_02_112

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

statement ok
CREATE TABLE TABLE_F131_04_02_122 ( ID INT PRIMARY KEY, B INTEGER );

statement ok
CREATE VIEW VIEW_F131_04_02_12 AS SELECT A FROM TABLE_F131_04_02_121 GROUP BY A HAVING A = 5;

query B
SELECT B >= ( SELECT A FROM VIEW_F131_04_02_12 ) FROM TABLE_F131_04_02_122
