pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Jones <erik@myemma.com>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: Josh Williams <joshwilliams@ij.net>
Cc: emilu@encs.concordia.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: Get the max(value1, value2, value3) from a table
Date: Mon, 7 Jan 2008 17:16:58 -0600
Message-ID: <53C367DF-24B3-425C-9EE7-BBA7336D3A89@myemma.com> (raw)
In-Reply-To: <dcc563d10801071443g3c91a29sd27ce5bdf6c4652b@mail.gmail.com>
References: <4782A1B2.5050804@encs.concordia.ca>
	<1199745537.5877.9.camel@godzilla.local.scalefeather.com>
	<dcc563d10801071443g3c91a29sd27ce5bdf6c4652b@mail.gmail.com>


On Jan 7, 2008, at 4:43 PM, Scott Marlowe wrote:

> On Jan 7, 2008 4:38 PM, Josh Williams <joshwilliams@ij.net> wrote:
>> On Mon, 2008-01-07 at 17:03 -0500, Emi Lu wrote:
>>> select ?max?(col1, col2, col3) as result;
>>> will return
>>>
>>> result
>>> -------
>>> 5
>>> 8
>>> 12
>>>
>>> (3 rows)
>>
>> 8.1 (I believe?) introduced GREATEST(), which does precisely what  
>> you're
>> looking for.
>
> How would greatest give him three rows like that?  Maybe I'm
> misunderstanding what the OP was asking for...

His test data was:

col1  col2  col3
----------------------
1          5   2
8          1   3
12        1  1

So, SELECT test(col1, col2, col3);

returning

test
-----
5
8
12

Is giving the max of the three columns for each row.
Erik Jones

DBA | Emma®
erik@myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com






view thread (11+ messages)

Message-ID: <53C367DF-24B3-425C-9EE7-BBA7336D3A89@myemma.com>
Permalink:  ../53C367DF-24B3-425C-9EE7-BBA7336D3A89@myemma.com/
Also on:    postgresql.org/message-id/53C367DF-24B3-425C-9EE7-BBA7336D3A89@myemma.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: erik@myemma.com, scott.marlowe@gmail.com, joshwilliams@ij.net, emilu@encs.concordia.ca
  Subject: Re: Get the max(value1, value2, value3) from a table
  In-Reply-To: <53C367DF-24B3-425C-9EE7-BBA7336D3A89@myemma.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox