[sqlite] SQL Challenge, select stack

2007-07-20 Thread Ken
Does anyone have ideas on how to implement a stack using sql 
  Given the following tables and data:
  
  create table stack( id integer primary key,   value integer);
  create table stackpop ( id integer primary key, value integer );
  
  begin;
  insert into stack values (1, 1234);
  insert into stack values (2, 1234);
  insert into stack values (6, 1234);
  insert into stack values (9, 1234);
 insert into stack values (22, 1234);
 
  insert into stackpop values (12, 1234) ;
  insert into stackpop values (14, 1234) ;
  insert into stackpop values (18, 1234) ;
  commit;
 
  Do you have any ideas for a select that will return the stackpop and stack 
id's paired as follows:
  12 | 9 
  14 | 6
  18 | 2  
  
  
  Thanks for your help!
  ken
 
 



[sqlite] SQL Challenge: select stack

2007-07-19 Thread Ken
Does anyone have ideas on how to implement a stack using sql 
 Given the following tables and data:
 
 create table stack( id integer primary key,   value integer);
 create table stackpop ( id integer primary key, value integer );
 
 begin;
 insert into stack values (1, 1234);
 insert into stack values (2, 1234);
 insert into stack values (6, 1234);
 insert into stack values (9, 1234);
 commit;
 
 begin;
 insert into stackpop values (12, 1234) ;
 insert into stackpop values (14, 1234) ;
 insert into stackpop values (18, 1234) ;
 commit;
 
 Do you have any ideas for a select that will return the stackpop and stack 
I'ds paired as follows:
 12 | 9 
 14 | 6
 18 | 2  
 
 
 Thanks for your help!
 ken