Re: Problem with aliasing

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Problem with aliasing
Дата
Msg-id 87bs1522hg.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Problem with aliasing  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
Ответы Re: Problem with aliasing
Список pgsql-general
Jean-Christian Imbeault <jc@mega-bucks.co.jp> writes:

> TAL=# select max(req_del_date1, req_del_date2, req_del_date3) as ma1 from
> invoices where ma1 <= now();
> ERROR:  Attribute "ma1" not found
>
> What is wrong with my syntax?

Try either of:

  SELECT max(req1, req2, req3) AS max FROM invoices WHERE max(req1, req2, req3) <= now()
  SELECT * from (select max(req1, req2, req3) AS max FROM invoices) WHERE max <= now()

Whichever seems clearer to you, I think postgres actually runs the two the
same way. Note, you should mark your function immutable so postgres knows it
can optimize the second case into the first.

--
greg

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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: Authentication to run pg_dump automatically
Следующее
От: "Berend Tober"
Дата:
Сообщение: Re: How to drop all the sequences