Re: Reuse of Subselects
От | Martijn van Oosterhout |
---|---|
Тема | Re: Reuse of Subselects |
Дата | |
Msg-id | 20040217122219.GB32685@svana.org обсуждение исходный текст |
Ответ на | Reuse of Subselects (Holger Marzen <holger@marzen.de>) |
Список | pgsql-general |
Depend in the exact query, you can do: SELECT column1, x.c, column1-x.c FROM table1, (... complicated subselect ...) as x; The above may not work if they're correlated, so you can try: SELECT column1, column2, column1-column2 FROM (SELECT column1, (... complicated subselect ...) as column2 FROM table1); Hope this helps, On Tue, Feb 17, 2004 at 01:02:43PM +0100, Holger Marzen wrote: > Hi all, > > if I have something like this: > > SELECT column1, > (... complicated subselect ...), > column1 - (... same subselect as above ...) > FROM table1; > > do I really have to rewrite the subselect a 2nd time if I need that > result in another column's expression? > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > If the Catholic church can survive the printing press, science fiction > will certainly weather the advent of bookwarez. > http://craphound.com/ebooksneitherenorbooks.txt - Cory Doctorow
Вложения
В списке pgsql-general по дате отправления: