The following bug has been logged online: Bug reference: 4290 Logged by: Andreas Email address: [EMAIL PROTECTED] PostgreSQL version: 8.3.3 Operating system: Linux Description: wrong double subselect with aggregate function Details:
select version() ; version ---------------------------------------------------------------------------- ------ PostgreSQL 8.3.3 on i486-pc-linux-gnu, compiled by GCC cc (Debian 4.3.1-1) 4.3.1 create table a ( id serial primary key ) ; create table b ( id serial primary key , aid int not null references a ) ; create table c ( id serial primary key , aid int not null references a ) ; create table d ( id serial primary key , bid int not null references b , cid int references b ) ; insert into a ( id ) values ( default ) , ( default ) ; insert into b ( aid ) values ( 1 ) , ( 2 ) ; insert into c ( aid ) values ( 1 ) , ( 1 ) , ( 2 ) , ( 2 ) ; insert into d ( bid ) values ( 1 ) , ( 2 ) ; select ( select min( c.id ) from c where c.aid = ( select b.aid from b where b.id = d.bid ) ) as min_c_id , ( select b.aid from b where b.id = d.bid ) as b_aid , ( select min( c.id ) from c where c.aid = 1 ) as min_c_id_1 , ( select min( c.id ) from c where c.aid = 2 ) as min_c_id_2 from d ; min_c_id | b_aid | min_c_id_1 | min_c_id_2 ----------+-------+------------+------------ 1 | 1 | 1 | 3 1 | 2 | 1 | 3 I expected for min_c_id in the second row 3. Best Regards Andreas -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs