Re: Find min and max values across two columns?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Find min and max values across two columns?
Дата
Msg-id 10495.1143235231@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Find min and max values across two columns?  (Rod Taylor <pg@rbt.ca>)
Ответы Re: Find min and max values across two columns?  (Rod Taylor <pg@rbt.ca>)
Список pgsql-sql
Rod Taylor <pg@rbt.ca> writes:
> The reason for the subselect is to prevent multiple calculations of
> individual column aggregates. I believe it *may* be calculated multiple
> times otherwise this would work just as well:

> select case when max(a) > max(b) then max(a) else max(b) end as max from
> tab;

Just for the record, we've gotten that right since 7.4.  greatest()
would be a notationally cleaner solution than CASE, but multiple
occurrences of identical aggregates don't cost much of anything.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Find min and max values across two columns?
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: Find min and max values across two columns?