drop table a if exists;
drop table b if exists;
drop table c if exists;
CREATE TABLE A(ID INTEGER NOT NULL)
CREATE TABLE B(ID INTEGER NOT NULL)
CREATE TABLE C(ID INTEGER NOT NULL)
INSERT INTO A VALUES(1)
INSERT INTO A VALUES(2)
INSERT INTO A VALUES(3)
INSERT INTO B VALUES(1)
INSERT INTO B VALUES(2)
INSERT INTO C VALUES(3)
INSERT INTO C VALUES(4)
INSERT INTO C VALUES(5)
/*e*/SELECT * FROM A UNION (SELECT * FROM C
/*e*/SELECT * FROM A UNION SELECT * FROM C)
/*e*/(SELECT * FROM A UNION (SELECT * FROM C
/*e*/(SELECT * FROM A
/*c5*/SELECT * FROM A UNION SELECT * FROM C
/*c5*/(SELECT * FROM A) UNION SELECT * FROM C
/*c5*/SELECT * FROM A UNION (SELECT * FROM C)
/*c5*/(SELECT * FROM A UNION SELECT * FROM C)
/*c3*/SELECT * FROM A UNION SELECT * FROM B
/*c5*/SELECT * FROM B UNION SELECT * FROM C
/*c2*/SELECT * FROM A EXCEPT SELECT * FROM C
/*c2*/(SELECT * FROM A) EXCEPT SELECT * FROM C
/*c2*/SELECT * FROM A EXCEPT (SELECT * FROM C)
/*c1*/(SELECT * FROM A INTERSECT SELECT * FROM C)
/*c2*/SELECT * FROM A INTERSECT (SELECT * FROM B)
/*c0*/(SELECT * FROM B) INTERSECT SELECT * FROM C
/*r
 1
 2
 3
*/SELECT * FROM A UNION SELECT * FROM C INTERSECT SELECT * FROM B
/*r
 1
 2
*/(SELECT * FROM A UNION SELECT * FROM C) INTERSECT SELECT * FROM B
/*r
*/SELECT * FROM A EXCEPT SELECT * FROM C EXCEPT SELECT * FROM B
/*r
 3
*/SELECT * FROM A UNION SELECT * FROM C INTERSECT SELECT * FROM B EXCEPT SELECT * FROM B
/*r
 1
 2
 3
*/SELECT * FROM A UNION SELECT * FROM C INTERSECT (SELECT * FROM B EXCEPT SELECT * FROM B)
CREATE VIEW V1 AS (SELECT * FROM A UNION SELECT * FROM C) INTERSECT SELECT * FROM B
/*r
 1
 2
*/SELECT * FROM V1
CREATE VIEW V3 AS SELECT * FROM A UNION SELECT * FROM C INTERSECT (SELECT * FROM B EXCEPT SELECT * FROM B)
/*r
 1
 2
 3
*/SELECT * FROM V3;
/*c3*/SELECT * FROM A WHERE ID IN (SELECT * FROM A UNION SELECT * FROM C INTERSECT (SELECT * FROM B EXCEPT SELECT * FROM B))
/*c3*/SELECT * FROM A WHERE EXISTS (SELECT * FROM A UNION SELECT * FROM C INTERSECT (SELECT * FROM B EXCEPT SELECT * FROM B))
/*c0*/SELECT * FROM A WHERE EXISTS (SELECT * FROM A EXCEPT SELECT * FROM C EXCEPT SELECT * FROM B)

