pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Greg Stark <gsstark@mit.edu>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: Stefan Bill <sjb26@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: LEAST and GREATEST functions?
Date: Tue, 1 Jul 2003 15:22:07 -0500
Message-ID: <20030701202207.GA4463@wolff.to> (raw)
In-Reply-To: <87d6gu2otf.fsf@stark.dyndns.tv>
References: <20030630201057.14507.qmail@web13905.mail.yahoo.com>
	<200306302032.23113.josh@agliodbs.com>
	<87d6gu2otf.fsf@stark.dyndns.tv>

On Tue, Jul 01, 2003 at 12:29:16 -0400,
  Greg Stark <gsstark@mit.edu> wrote:
> 
> SELECT greatest(a,b) FROM bar
> 
> would return one tuple for every record in the table with a single value
> representing the greater of bar.a and bar.b.

You can do this with case.

SELECT CASE WHEN a >= b THEN a ELSE b END FROM bar;



view thread (14+ messages)  latest in thread

Message-ID: <20030701202207.GA4463@wolff.to>
Permalink:  ../20030701202207.GA4463@wolff.to/
Also on:    postgresql.org/message-id/20030701202207.GA4463@wolff.to

 · 

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: bruno@wolff.to, gsstark@mit.edu, josh@agliodbs.com, sjb26@yahoo.com
  Subject: Re: LEAST and GREATEST functions?
  In-Reply-To: <20030701202207.GA4463@wolff.to>

* 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