Rafal Pietrak wrote: > Gurjeet, > > Focusing on the standars solution, I did some 'exercises' - works fine, > just learning. > > But the ambarasing thing is, that I looks like I really don't get it, > meaning - what exactly the internal query does. I've never ever seen or > used a subquery with data/params from 'upper level' query used within a > subquery - any time I've written a hierarchical query (e.g. with > subqueries), the relations were always hierarchical. In other words, I > was always able to run an internal subquery outside of the compound > query and get consistant results. With this one I cannot do that due to > the 'entanglement' of t3 and t1. This is called a 'correlated subquery'. Basically the subquery is performed for each record in the top query. Google gave me this: http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/sqlp/rbafycorrs.htm And there's probably more to find. Interestingly enough wikipedia doesn't seem to have an article on the subject. > Postgress query plan from EXPLAIN doesn't help me here - probably I'm > unable to interpret it correctly without 'a paradigm mind shift'. > > So, would you mind commenting a little on how exactly the t1.id > influences subquery (with t3), and the result influences back the > selection of t1 set? > > Will greatly apreciate that. -- Alban Hertroys alban@xxxxxxxxxxxxxxxxx magproductions b.v. T: ++31(0)534346874 F: ++31(0)534346876 M: I: www.magproductions.nl A: Postbus 416 7500 AK Enschede // Integrate Your World //