Re: UNION question

Поиск
Список
Период
Сортировка
От Brandon Metcalf
Тема Re: UNION question
Дата
Msg-id Pine.LNX.4.58L.0907101133520.6574@cedar.geronimoalloys.com
обсуждение исходный текст
Ответ на Re: UNION question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
t == tgl@sss.pgh.pa.us writes:

 t> Brandon Metcalf <brandon@geronimoalloys.com> writes:
 t> > I tried moving the last group of WHERE, GROUP BY, and ORDER BY before
 t> > the UNION with the query it belongs to, but that results in a
 t> > different syntax error.

 t> I think that's probably what you want to do.  What you're missing is
 t> you need parentheses to put an ORDER BY into an arm of a UNION:

 t> (SELECT ... ORDER BY ...) UNION SELECT ...

 t> Otherwise it wants to consider the ORDER BY as applying to the UNION
 t> output.


Indeed.  It was the fact that I was trying to move the ORDER BY along
with WHERE and GROUP BY that was giving me grief.

Thanks.

--
Brandon

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

Предыдущее
От: Brandon Metcalf
Дата:
Сообщение: Re: UNION question
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: SELECT DISTINCT very slow