Re: Get the max(value1, value2, value3) from a table

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Get the max(value1, value2, value3) from a table
Date: 2008-01-07 22:37:56
Message-ID: 4782A9C4.1030104@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


>
>> select max(col1) from table
>> union all
>> select max(col2) from table
>> union all
>> select max(col3) from table
No, this is not what I prefer; it makes complicate query.

>
> Would the following work also?
>
> SELECT MAX( GREATEST( col1, col2, col3 ) )
> FROM TABLE;

I would prefer this func. Unfortunately, the current version I have
8.02(http://www.postgresql.org/docs/8.0/static/functions-conditional.html)
does not support this func I am afraid :(

Thanks !
Ly.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Williams 2008-01-07 22:38:57 Re: Get the max(value1, value2, value3) from a table
Previous Message Scott Marlowe 2008-01-07 22:37:52 Re: Get the max(value1, value2, value3) from a table