Select max field

From: Bob Kruger <bkruger(at)mindspring(dot)com>
To: pgsql-sql(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Select max field
Date: 1999-02-10 19:42:44
Message-ID: 3.0.5.32.19990210134244.007a8b10@mindspring.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

I am looking for a way to determine the largest value of a number of fields
in a tuple.

Example: In a table with the fields id_no, t1, t2 ,t3 ,t4 ,t5
Select the id_no and the greatest value from fields t1, t2, t3,
t4, t5.

I have tried the following, but with no success:

select id_no, max(t1, t2, t3, t4, t5) from table_1 ;

Anyone have any suggestions?

Thanks in advance for any assistance.

Regards - Bob

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ricardo J.C.Coelho 1999-02-10 21:40:27 RES: [GENERAL] Select max field
Previous Message Bryan White 1999-02-10 19:05:41 How to improve performance

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Mönnich 1999-02-10 21:32:08 Outer Joins
Previous Message Fabrice Scemama 1999-02-10 05:23:13 [Fwd: [SQL] Using Indexes with Pg]IamReal.