Re: LIMIT within UNION?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: LIMIT within UNION?
Дата
Msg-id 20020912124808.N48644-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на LIMIT within UNION?  (Andrew Perrin <clists@perrin.socsci.unc.edu>)
Ответы Re: LIMIT within UNION?
Список pgsql-sql
On Thu, 12 Sep 2002, Andrew Perrin wrote:

> Greetings-
>
> I have a table of participants to be contacted for a study. Some are in
> the "exposure" group, others in the "control" group. This is designated by
> a column, typenr, that contains 1 for exposure, 2 for control.
>
> The complication is this: I need to select 200 total. The 200 number
> should include *all* those eligible in the exposure group, plus enough
> from the control group to bring the total number up to 200. (Yes, there is
> a valid reason for this.) Furthermore, I need to sort the output of the
> two groups *together* by zip code.

Do you get more than 200 if there are more eligible people and does the
... ever include the same person in both sides of the union?

If not in the second case, union all would probably save the database
some extra work since it won't have to try to weed out duplicates.

If not in the first case, then wouldn't a limit 200 on the after union
result set work rather than a separate count and subtraction?




В списке pgsql-sql по дате отправления:

Предыдущее
От: Tim Perdue
Дата:
Сообщение: Re: Latitude / Longitude
Следующее
От: Andrew Perrin
Дата:
Сообщение: Re: LIMIT within UNION?