Re: Find min and max values across two columns?

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amos Hayes <ahayes(at)polkaroo(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Find min and max values across two columns?
Date: 2006-05-15 21:50:08
Message-ID: 1147729808.9755.157.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 2006-05-15 at 16:40, Emi Lu wrote:
> Hello,
>
> I tried "select greatest(max(a), max(b)) from public.test", but I got
> the following errors:
>
> ERROR: function greatest(integer, integer) does not exist
> HINT: No function matches the given name and argument types. You may
> need to add explicit type casts.
>
> May I know where I can read the docs about greatest & least please.
>
> I am using PostgreSQL 8.0.7.

You need to define your problem better. Assuming these data:

a b
12 24
24 12
13 18
25 10

which should I get for greatest(max(a), max(b)) should I get? Do you
just want 25,24??? In that case you don't need greatest. Do you need
the highest total between the two, or what?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jose Apablaza 2006-05-15 22:19:03 MySQL DB to PostgresSQL DB
Previous Message Emi Lu 2006-05-15 21:40:40 Re: Find min and max values across two columns?