Received: from zeus.houstoncellular.com (zeus.houstoncellular.com [206.109.152.194]) by hub.org (8.9.1/8.9.1) with ESMTP id QAA23268 for ; Wed, 2 Dec 1998 16:57:45 -0500 (EST) (envelope-from YoungblG@houstoncellular.com) Received: by SCORPEXC1.houstoncell.com with Internet Mail Service (5.5.2232.9) id ; Wed, 2 Dec 1998 15:57:08 -0600 Message-ID: <2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.com> From: Greg Youngblood To: "'PostgreSQL SQL List'" Subject: Please help: How to determine largest of two numbers in a query? Date: Wed, 2 Dec 1998 15:55:17 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2232.9) Content-Type: text/plain; charset="iso-8859-1" I have a table with the following structure: yyyymmdd int4 key char(16) value1 int4 value2 int4 with the following sample data: yyyymmdd key value1 value2 19981201 hello 32 16 19981201 bye 29 64 19981202 hello 16 20 19981202 bye 23 13 What I need is to select the greatest between value1 and value2, so the answer would be: yyyymmdd key value 19981201 hello 32 19981201 bye 64 19981202 hello 20 19981202 bye 23 I can do this via ODBC using access by creating a column which is defined as IF(value1>value2,value1,value2) but that doesn't work in psql. How can I make this work in psql? Thanks Greg