pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <scott.marlowe@gmail.com>
To: 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 16:16:04 -0600
Message-ID: <dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.com> (raw)
In-Reply-To: <4782A1B2.5050804@encs.concordia.ca>
References: <4782A1B2.5050804@encs.concordia.ca>

On Jan 7, 2008 4:03 PM, Emi Lu <emilu@encs.concordia.ca> wrote:
> 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

select max(col1) from table
union all
select max(col2) from table
union all
select max(col3) from table



view thread (11+ messages)  latest in thread

Message-ID: <dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.com>
Permalink:  ../dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.com/
Also on:    postgresql.org/message-id/dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.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: scott.marlowe@gmail.com, emilu@encs.concordia.ca
  Subject: Re: Get the max(value1, value2, value3) from a table
  In-Reply-To: <dcc563d10801071416y4084231fie0261030ef4e071a@mail.gmail.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