From: | Andrew Perrin <clists(at)perrin(dot)socsci(dot)unc(dot)edu> |
---|---|
To: | Roland Roberts <roland(at)astrofoto(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: LIMIT within UNION? |
Date: | 2002-09-12 19:41:51 |
Message-ID: | Pine.LNX.4.21.0209121540540.32000-100000@perrin.socsci.unc.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 12 Sep 2002, Roland Roberts wrote:
> >>>>> "Andrew" == Andrew Perrin <clists(at)perrin(dot)socsci(dot)unc(dot)edu> writes:
> ...
> 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;
>
Unfortunately in this case the LIMIT is applied to the fully-UNIONed set,
limiting the total number of cases to 172 instead of just those from the
second subquery. Tom Lane's example worked, though.
Thanks,
Andy
----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists(at)perrin(dot)socsci(dot)unc(dot)edu * andrew_perrin (at) unc.edu
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2002-09-12 19:46:51 | Re: [SQL] Latitude / Longitude |
Previous Message | Andrew Perrin | 2002-09-12 19:40:46 | Re: LIMIT within UNION? |