Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AF6CD476C02 for ; Thu, 12 Sep 2002 15:35:14 -0400 (EDT) Received: from mail.astrofoto.org (dsl092-102-177.nyc2.dsl.speakeasy.net [66.92.102.177]) by postgresql.org (Postfix) with ESMTP id 02E1A476A5F for ; Thu, 12 Sep 2002 15:35:14 -0400 (EDT) Received: from kuiper.rlent.pnet (IDENT:root@kuiper.rlent.pnet [192.168.3.50]) by mail.astrofoto.org (8.12.3/8.12.3) with ESMTP id g8CJZEtV032327 for ; Thu, 12 Sep 2002 15:35:14 -0400 Received: (from roland@localhost) by kuiper.rlent.pnet (8.11.6/8.11.6) id g8CJZEZ11116; Thu, 12 Sep 2002 15:35:14 -0400 X-Authentication-Warning: kuiper.rlent.pnet: roland set sender to roland@astrofoto.org using -f To: pgsql-sql@postgresql.org Subject: Re: LIMIT within UNION? References: From: Roland Roberts Date: 12 Sep 2002 15:35:14 -0400 In-Reply-To: Message-ID: Lines: 31 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/113 X-Sequence-Number: 9390 >>>>> "Andrew" == Andrew Perrin writes: Andrew> What I've done is to write a script that counts the number Andrew> of eligible exposure candidates: Andrew> SELECT count(*) FROM participants WHERE Andrew> AND typenr=1 Andrew> Then subtract that number (currently 28) from 200 to get Andrew> 172 control participants. Then the problem starts. [...] Andrew> returns ERROR: parser: parse error at or near "ORDER" Can you do this via a subselect: SELECT * FROM ( SELECT ... FROM participants WHERE typenr=1 AND UNION SELECT ... FROM participants WHERE typenr=2 LIMIT 172 ) ORDER BY zip; roland -- PGP Key ID: 66 BC 3B CD Roland B. Roberts, PhD RL Enterprises roland@rlenter.com 76-15 113th Street, Apt 3B roland@astrofoto.org Forest Hills, NY 11375