Re: SQL Help

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: C F <tacnaboyz(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL Help
Date: 2003-05-30 16:37:12
Message-ID: 200305300937.12158.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

  • SQL Help at 2003-05-30 15:47:03 from C F

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2003-05-30 16:40:06 Re: CASE returning multiple values (was SQL Help)
Previous Message Bruno Wolff III 2003-05-30 16:30:40 Re: SQL Help