Re: Find min and max values across two columns?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Find min and max values across two columns?
Дата
Msg-id 9558.1143234035@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Find min and max values across two columns?  (Amos Hayes <ahayes@polkaroo.net>)
Ответы Re: Find min and max values across two columns?  ("Jim C. Nasby" <jnasby@pervasive.com>)
Re: Find min and max values across two columns?  (Emi Lu <emilu@encs.concordia.ca>)
Список pgsql-sql
Amos Hayes <ahayes@polkaroo.net> writes:
> I'm trying to build a query that among other things, returns the  
> minimum and maximum values contained in either of two columns.

I think you might be looking for
select greatest(max(columnA), max(columnB)) from tab;select least(min(columnA), min(columnB)) from tab;

greatest/least are relatively new but you can roll your own in
older PG releases.
        regards, tom lane


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

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