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

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Get the max(value1, value2, value3) from a table
Date: 2008-01-07 22:03:30
Message-ID: 4782A1B2.5050804@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

(3 rows)

Thanks!
Ly.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-01-07 22:16:04 Re: Get the max(value1, value2, value3) from a table
Previous Message gherzig 2008-01-07 20:47:09 Re: reading WAL files in python