Re: Find min and max values across two columns?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: 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-16 00:08:05
Message-ID: 441.1147738085@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Emi Lu <emilu(at)encs(dot)concordia(dot)ca> writes:
> 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.

We added greatest/least in 8.1, but before that you can just use a
CASE expression instead, along the lines of
case when x>y then x else y end

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message lingyu.tseng 2006-05-16 04:05:20 how referencing %rowtype variables without column names
Previous Message Jeff MacDonald 2006-05-15 23:26:15 Re: MySQL DB to PostgresSQL DB