Re: How to obtain the maximum value of a date, between 3 tables...

Поиск
Список
Период
Сортировка
От bricklen
Тема Re: How to obtain the maximum value of a date, between 3 tables...
Дата
Msg-id AANLkTikzc24QuaQJde6urOGWpV51SJdOAqZr_Bz-_6UX@mail.gmail.com
обсуждение исходный текст
Ответ на How to obtain the maximum value of a date, between 3 tables...  (Andre Lopes <lopes80andre@gmail.com>)
Список pgsql-general
On Wed, Dec 8, 2010 at 5:15 AM, Andre Lopes <lopes80andre@gmail.com> wrote:
> Hi,
>
> I need to obtain the maximum value of a date, but that comparison will be
> made between 3 tables... I will explain better with a query...
>
> [code]
> select
> a.last_refresh_date as d1, ae.last_refresh_date as d2, ha.last_refresh_date
> as d3
> from tbl1 a
> join tbl2 ae on a.id_anuncio_externo = ae.id_anuncio_externo
> join tbl3 ha on a.id_anuncio_externo = ha.id_anuncio_externo
> [/code]
>
> My question is how is the best way to obtain with date is the greatest, d1,
> d2 or d3
>
> Can you guys give me a clue.
>
> Best Regards,
>

How about using GREATEST?

http://www.postgresql.org/docs/8.4/interactive/functions-conditional.html
(9.16.4)

select GREATEST(d1,d2,d3)
from (...)

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Maximum size for char or varchar with limit
Следующее
От: Vick Khera
Дата:
Сообщение: Re: SELECT is immediate but the UPDATE takes forever