pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roland Roberts <roland@astrofoto.org>
To: pgsql-sql@postgresql.org
Subject: Re: LIMIT within UNION?
Date: 12 Sep 2002 15:35:14 -0400
Message-ID: <m27khrovbh.fsf@kuiper.rlent.pnet> (raw)
In-Reply-To: <Pine.LNX.4.21.0209121454540.32000-100000@perrin.socsci.unc.edu>
References: <Pine.LNX.4.21.0209121454540.32000-100000@perrin.socsci.unc.edu>

>>>>> "Andrew" == Andrew Perrin <clists@perrin.socsci.unc.edu> 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 <eligibility>
    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 <eligibility>
      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



view thread (10+ messages)  latest in thread

Message-ID: <m27khrovbh.fsf@kuiper.rlent.pnet>
Permalink:  ../m27khrovbh.fsf@kuiper.rlent.pnet/
Also on:    postgresql.org/message-id/m27khrovbh.fsf@kuiper.rlent.pnet

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: roland@astrofoto.org
  Subject: Re: LIMIT within UNION?
  In-Reply-To: <m27khrovbh.fsf@kuiper.rlent.pnet>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox