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

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Get the max(value1, value2, value3) from a table
Date: 2008-01-07 22:16:04
Message-ID: dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Jan 7, 2008 4:03 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:
> Greetings,
>
> Version: PostgreSQL 8.0.13 on i686-pc-linux-gnu
>
> I have a table test(col1, col2, col3)
>
> For each row, I'd like to get the "max"(col1, col2, col3).
>
> For example, test(1, 5, 2)
> test(8, 1, 3)
> test(12, 1, 1)
>
>
> select ?max?(col1, col2, col3) as result;
> will return
>
> result
> -------
> 5
> 8
> 12

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma Jr 2008-01-07 22:27:40 Re: Get the max(value1, value2, value3) from a table
Previous Message Emi Lu 2008-01-07 22:03:30 Get the max(value1, value2, value3) from a table