Ken <kennethinbox-sqlite-/[EMAIL PROTECTED]> wrote:
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

select s.id, p.id from stack s, stackpop p
where s.value = p.value and
(select count(*) from stackpop p2 where p2.value=p.value and p2.id < p.id) = (select count(*) from stack s2 where s2.value=s.value and s2.id > s.id);

I predict this query will run very slowly for any sizeable amount of data. You are trying to fit a proverbial square peg into a round hole.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to