drop view if exists v_j1;

create view v_j1 as select * from j1 where j1_key in (1,3,5,7,9,11,13,15);

select j1_key, j6_key, j11_key from j6 join j1 on j1_key = j6_key right join j11 on j6_key = j11_key where j1_key in (1,3,5,7,9,11,13,15) order by 1, 2, 3; 
select j1_key, j6_key, j11_key from j6 join v_j1 on j1_key = j6_key right join j11 on j6_key = j11_key order by 1, 2, 3; 

select j1_key, j6_key, j11_key from j6 left join v_j1 on j1_key = j6_key right join j11 on j6_key = j11_key order by 1, 2, 3; 

select j1_key, j6_key, j11_key from j6 left join v_j1 on j1_key = j6_key right join j11 on j6_key = j11_key where j1_key >= 2 order by 1, 2, 3; 

select j1_key, j6_key, j11_key from j6 left join v_j1 on j1_key = j6_key right join j11 on j6_key = j11_key where j1_key >2 or j1_key is null order by 1, 2, 3;

select j1_key, j6_key, j11_key from j6 left join v_j1 on j1_key = j6_key left join j11 on j6_key = j11_key where j1_key >= 2 order by 1, 2, 3; 

select j1_key, j6_key, j11_key from j6 right join j1 on j1_key = j6_key right join j11 on j6_key = j11_key where j1_key in (1,3,5,7,9,11,13,15) order by 1, 2, 3; 
select j1_key, j6_key, j11_key from j6 right join v_j1 on j1_key = j6_key right join j11 on j6_key = j11_key order by 1, 2, 3; 

select j1_key, j6_key, j11_key from j6 right join j11 on j11_key = j6_key right join v_j1 on j6_key = j1_key order by 1, 2, 3; 

select j1_key, j6_key, j11_key from v_j1 left join j6 on j1_key=j6_key left
 join j11 on j6_key = j11_key order by 1, 2, 3; 

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j6_key = j11_key order by 3, 2, 1; 

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j6_key = j11_key right join j16 on j11_key = j16_key order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j1_key = j11_key right join j16 on j1_key = j16_key order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j1_key = j11_key right join j16 on j1_key = j16_key where j11_key > 0 order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j1_key = j11_key right join j16 on j1_key = j16_key where j11_key > 0 or j11_key is null order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j6_key = j11_key where j6_key > 0 order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j6_key = j11_key where j6_key > 0 or j6_key is null order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key right join j11 on j6_key = j11_key where j6_key > 12 or j6_key is null order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key where j6_key < 19 order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key where j6_key < 19 and j1_key > 7 order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key where j6_key < 19 and j1_key > 7 or j1_key is null order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key where j6_key < 19 and j1_key is not null or j1_key is null order by 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key left join j16 on j11_key = j16_key where j6_key < 19 and j1_key is not null or j1_key is null order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 right join j6 on j1_key=j6_key left join j11 on j6_key = j11_key right join j16 on j11_key = j16_key where j6_key < 19 and j1_key is not null or j1_key is null order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key, j16_key from v_j1 left join j6 on j1_key=j6_key left join j11 on j1_key = j11_key right join j16 on j11_key = j16_key where j6_key < 19 and j1_key is not null or j1_key is null order by 4, 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 left join j6 on j1_key=j6_key right join j11 on j1_key = j11_key where j6_key=13 order by 3, 2, 1;

select j1_key, j6_key, j11_key from v_j1 left join j6 on j1_key=j6_key right join j11 on j1_key = j11_key where j6_key=13 or j6_key is null order by 3, 2, 1;

drop view if exists v_j1;

