Re: LIMIT within UNION? - Mailing list pgsql-sql

From Andrew Perrin
Subject Re: LIMIT within UNION?
Date
Msg-id Pine.LNX.4.21.0209121540540.32000-100000@perrin.socsci.unc.edu
Whole thread Raw
In response to Re: LIMIT within UNION?  (Roland Roberts <roland@astrofoto.org>)
Responses Re: LIMIT within UNION?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
On 12 Sep 2002, Roland Roberts wrote:

> >>>>> "Andrew" == Andrew Perrin <clists@perrin.socsci.unc.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@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu






pgsql-sql by date:

Previous
From: Andrew Perrin
Date:
Subject: Re: LIMIT within UNION?
Next
From: Tim Perdue
Date:
Subject: Re: Latitude / Longitude