RES: [GENERAL] Select max field

From: "Ricardo J(dot)C(dot)Coelho" <pulsar(at)truenet-ce(dot)com(dot)br>
To: "'Bob Kruger'" <bkruger(at)mindspring(dot)com>, "pgsql-sql(at)postgreSQL(dot)org" <pgsql-sql(at)postgreSQL(dot)org>, "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>
Subject: RES: [GENERAL] Select max field
Date: 1999-02-10 21:40:27
Message-ID: 01BE552E.6A2F64A0.pulsar@truenet-ce.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Bob,

I think MAX aggregate function choose the maximum values of one field (or expression) in a set of rows. Not the max vaues of many fields.

----- Mensagem original -----
De: Bob Kruger [SMTP:bkruger(at)mindspring(dot)com]
Enviada em: Quarta-feira, 10 de Fevereiro de 1999 16:43
Para: pgsql-sql(at)postgreSQL(dot)org; pgsql-general(at)postgreSQL(dot)org
Assunto: [GENERAL] Select max field

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

Browse pgsql-general by date

  From Date Subject
Next Message Bob Dusek 1999-02-11 00:29:43 Re: [GENERAL] Select max field
Previous Message Bob Kruger 1999-02-10 19:42:44 Select max field

Browse pgsql-sql by date

  From Date Subject
Next Message Bob Dusek 1999-02-11 00:29:43 Re: [GENERAL] Select max field
Previous Message pierre 1999-02-10 21:34:28 Rule problem