IF..THEN..ELSE

From: "David J(dot) Haglin" <haglin(at)pike(dot)cs(dot)mankato(dot)msus(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: IF..THEN..ELSE
Date: 1998-09-17 15:46:17
Message-ID: 199809171546.KAA21063@pike.cs.mankato.msus.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

I'm kinda new to using PostgreSQL, and am somewhat mystified by
what appears to me to be a lack of a feature. Specifically, I
would like to be able to use an IF function in a SELECT, such as:

SELECT key,
IF (attr1>attr2, attr1, attr2) AS maxOfAttrs
INTO TABLE temp
FROM basic;

where the temp database would have a new column holding the larger
of the two attributes for each instance.

Is there an easy way to accomplish this that I am not seeing?

Thanks in advance for any help,

David

--
David J. Haglin David(dot)Haglin(at)mankato(dot)msus(dot)edu
Mankato State University http://pike.cs.mankato.msus.edu/~haglin
P.O. Box 8400 Voice: (507) 389-5306
Mankato, MN 56002-8400 Fax: (507) 389-6376

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 1998-09-17 16:00:20 Re: [SQL] Turn autocommit off ?
Previous Message Federico Passaro 1998-09-17 14:46:11 Re: [SQL] Turn autocommit off ?