Thread: IF..THEN..ELSE

IF..THEN..ELSE

From
"David J. Haglin"
Date:
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.Haglin@mankato.msus.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

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