Re: Find min and max values across two columns?

Поиск
Список
Период
Сортировка
От Emi Lu
Тема Re: Find min and max values across two columns?
Дата
Msg-id 4468F558.7070407@encs.concordia.ca
обсуждение исходный текст
Ответ на Re: Find min and max values across two columns?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Find min and max values across two columns?  (Scott Marlowe <smarlowe@g2switchworks.com>)
Re: Find min and max values across two columns?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hello,

I tried "select greatest(max(a), max(b)) from public.test",  but I got 
the following errors:

ERROR:  function greatest(integer, integer) does not exist
HINT:  No function matches the given name and argument types. You may 
need to add explicit type casts.

May I know where I can read the docs about greatest & least please.

I am using  PostgreSQL 8.0.7.

Thanks,
Ying



>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
>
>---------------------------(end of broadcast)---------------------------
>TIP 9: In versions below 8.0, the planner will ignore your desire to
>       choose an index scan if your joining column's datatypes do not
>       match
>  
>



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

Предыдущее
От: Jean-Paul Argudo
Дата:
Сообщение: Re: PL/PGSQL - How to pass in variables?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Find min and max values across two columns?