SQL Help - Mailing list pgsql-sql

From C F
Subject SQL Help
Date
Msg-id 20030530154703.37238.qmail@web20415.mail.yahoo.com
Whole thread Raw
Responses Re: SQL Help  (Bruno Wolff III <bruno@wolff.to>)
Re: SQL Help  (Josh Berkus <josh@agliodbs.com>)
Re: CASE returning multiple values (was SQL Help)  (Richard Huxton <dev@archonet.com>)
Re: SQL Help  (Franco Bruno Borghesi <franco@akyasociados.com.ar>)
List pgsql-sql
Hello,
I already tried this same basic question with no response....  maybe I was too wordy.  So here it is simplified.... what's the best way to write this query?  I'm open to using stored procedures, but even then I don't know how I would conditionally populate a resultset (refcursor).  Notice that in the first three cases, the expression is the exact same, only the return value is different.  This seems inefficient....
 

select
  (case when column1 = column2 then column3 end) as alias1,
  (case when column1 = column2 then column4 end) as alias2,
  (case when column1 = column2 then column5 end) as alias3,
  (case when column6 = column7 then column8 end) as alias4
from
  mytable
;
Any ideas? 
Thanks!


Do you Yahoo!?
Free online calendar with sync to Outlook(TM).

pgsql-sql by date:

Previous
From: "Jr."
Date:
Subject: Re: "record" datatype - plpgsql
Next
From: "David Klugmann"
Date:
Subject: SELECT statement within libpq