pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Youngblood <YoungblG@houstoncellular.com>
To: 'PostgreSQL SQL List' <pgsql-sql@postgresql.org>
Subject: Please help: How to determine largest of two numbers in a query?
Date: Wed, 2 Dec 1998 15:55:17 -0600
Message-ID: <2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.com> (raw)

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



view thread (4+ messages)  latest in thread

Message-ID: <2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.com>
Permalink:  ../2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.com/
Also on:    postgresql.org/message-id/2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: YoungblG@houstoncellular.com
  Subject: Re: Please help: How to determine largest of two numbers in a query?
  In-Reply-To: <2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.com>
  References: <2B9713A99045D211BB4E0008C75668692EA70C@SCORPEXC1.houstoncell.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