pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: C F <tacnaboyz@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: SQL Help
Date: Fri, 30 May 2003 09:37:12 -0700
Message-ID: <200305300937.12158.josh@agliodbs.com> (raw)
In-Reply-To: <20030530154703.37238.qmail@web20415.mail.yahoo.com>
References: <20030530154703.37238.qmail@web20415.mail.yahoo.com>

CF,

> 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

Given the information you've given us (including your first e-mail), I can't 
think of a better way to get the output you want than the above.  You could 
work through subselects, etc, but I think that would be even less efficient.

One thing you might want to think about is your whole approach to designing 
this application; it may be that you can simplify your queries by changing 
your table design.  

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (9+ messages)  latest in thread

Message-ID: <200305300937.12158.josh@agliodbs.com>
Permalink:  ../200305300937.12158.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200305300937.12158.josh@agliodbs.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: josh@agliodbs.com, tacnaboyz@yahoo.com
  Subject: Re: SQL Help
  In-Reply-To: <200305300937.12158.josh@agliodbs.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