Re: LEAST and GREATEST functions?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Stefan Bill <sjb26(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: LEAST and GREATEST functions?
Date: 2003-07-01 20:22:07
Message-ID: 20030701202207.GA4463@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Jul 01, 2003 at 12:29:16 -0400,
Greg Stark <gsstark(at)mit(dot)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;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2003-07-01 20:22:55 Re: LEAST and GREATEST functions?
Previous Message scott.marlowe 2003-07-01 20:13:31 Re: need some help with a delete statement