pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: C F <tacnaboyz@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: SQL Help
Date: Fri, 30 May 2003 08:47:03 -0700 (PDT)
Message-ID: <20030530154703.37238.qmail@web20415.mail.yahoo.com> (raw)

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).

view thread (9+ messages)  latest in thread

Message-ID: <20030530154703.37238.qmail@web20415.mail.yahoo.com>
Permalink:  ../20030530154703.37238.qmail@web20415.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030530154703.37238.qmail@web20415.mail.yahoo.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tacnaboyz@yahoo.com
  Subject: Re: SQL Help
  In-Reply-To: <20030530154703.37238.qmail@web20415.mail.yahoo.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