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

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Josh Williams <joshwilliams(at)ij(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Get the max(value1, value2, value3) from a table
Date: 2008-01-07 22:53:26
Message-ID: 4782AD66.3060606@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>> select ?max?(col1, col2, col3) as result;
>>> will return
>>>
>>> result
>>> -------
>>> 5
>>> 8
>>> 12
>>>
>>> (3 rows)
>> 8.1 (I believe?) introduced GREATEST(), which does precisely what you're
>> looking for.
>
> How would greatest give him three rows like that? Maybe I'm
> misunderstanding what the OP was asking for...

IF 8.1, "select greatest(col1, col2, col3) from test" is exactly what I
am looking for.

I would do the optional query by union/or for now.

Thanks!
Ly.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-01-07 23:16:21 Re: Get the max(value1, value2, value3) from a table
Previous Message Scott Marlowe 2008-01-07 22:43:27 Re: Get the max(value1, value2, value3) from a table