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

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

--- On Mon, 1/7/08, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:

> select max(col1) from table
> union all
> select max(col2) from table
> union all
> select max(col3) from table

Would the following work also?

SELECT MAX( GREATEST( col1, col2, col3 ) )
FROM TABLE;

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-sql by date

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