Re: SQL Help - Mailing list pgsql-sql

From Josh Berkus
Subject Re: SQL Help
Date
Msg-id 200305300937.12158.josh@agliodbs.com
Whole thread Raw
In response to SQL Help  (C F <tacnaboyz@yahoo.com>)
List 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


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: SQL Help
Next
From: Richard Huxton
Date:
Subject: Re: CASE returning multiple values (was SQL Help)