--
-- ### Nested views 
-- 
--

drop if exists table t1;
create table t1 ( a int , b string(10) );
create btree b1 on t1( a );

insert into t1 values ( 1, 'XXXX' );
insert into t1 values ( 2, 'YYYY' );
insert into t1 values ( 3, 'ZZZZ' );

insert into t1 values ( 10, 'ZZZZ' );
insert into t1 values ( 20, 'ZZZZ' );
insert into t1 values ( 30, 'ZZZZ' );

select a from t1;


drop if exists table t2;
create table t2 ( c int , d string(10) );
create btree b2 on t2( c );

insert into t2 values ( 1, 'XXXX' );
insert into t2 values ( 2, 'YYYY' );
insert into t2 values ( 3, 'ZZZZ' );

insert into t2 values ( 10, 'XXXX' );
insert into t2 values ( 20, 'YYYY' );
insert into t2 values ( 30, 'ZZZZ' );



drop if exists view v1;
create view v1 as select a as a from t1 where a < 10;

select * from v1;

drop if exists view v2;
create view v2 as select c from t2, v1 where t2.c = v1.a;

select * from v2;




