Received: from smtp2.mindspring.com (smtp2.mindspring.com [207.69.200.32]) by hub.org (8.9.2/8.9.1) with ESMTP id PAA28823 for ; Wed, 31 Mar 1999 15:04:47 -0500 (EST) (envelope-from clark.evans@manhattanproject.com) Received: from manhattanproject.com (pool-207-205-160-150.nwrk.grid.net [207.205.160.150]) by smtp2.mindspring.com (8.8.5/8.8.5) with ESMTP id PAA20305; Wed, 31 Mar 1999 15:04:37 -0500 (EST) Sender: clark@mindspring.com Message-ID: <37027EED.1FC9EA51@manhattanproject.com> Date: Wed, 31 Mar 1999 20:00:45 +0000 From: Clark Evans X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: MESZAROS Attila CC: pgsql-sql@hub.org Subject: Re: [SQL] select ... from (select .. from where.. ) where ... ? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit MESZAROS Attila wrote: > I'am faced with a huge system using the above kind of queries. > It was originally written and tested with adabas. I wrote a hudge system using those kind of queries. Very useful buggers, really helps you manage complexity. I bet it plays hudge games with the optimizer though... > Unfortunatelly 6.4 does support subqueries only in the 'where' expression, > as far as I undersood... That's my understanding. 6.5 will not support it either. > My questions are: > How can I port this program with the least effort? > Shall I create views corresponding to the subqueries, > and doing the outer select on a view? You can do this, as long as the inner select does not have an aggregate. If it has an aggregate _or_ uses an outer join then you need to code up functions that do the outer-join. > Is is planned to implement this feature in the near future? I hope so. Actually, I think this is a generalization of the HAVING clause. About 2 years ago (using Oracle) I dropped using the HAVING clause due to this form... so, there is another possibility, see if you can re-write these queries to use HAVING. Let me know if I can help more. Clark