pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Little, Douglas <DOUGLAS.LITTLE@orbitz.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: how to: refer to select list calculations other places in the calculations.
Date: Thu, 10 Sep 2009 10:32:40 -0600
Message-ID: <4AA92A28.1060902@gmail.com> (raw)
In-Reply-To: <A434C531E37AD442815608A769550D80590432A7A3@EGEXCMB01.oww.root.lcl>
References: <A434C531E37AD442815608A769550D80590432A1BC@EGEXCMB01.oww.root.lcl>
	<4AA88783.1040204@gmail.com>
	<A434C531E37AD442815608A769550D80590432A7A3@EGEXCMB01.oww.root.lcl>

I might do the substitution, analyse the query and hope to break it up. 
Can it possibly be optimal?

Little, Douglas wrote:
> Hi Rob, 
> Thanks for the response.
> Repeating the base calculation will work but the calculations are  stunningly complex and long.  Repeating them will undoubtly increase editing errors and maintenance problems. 
>
> Wish I had a sample to post.  Last query I analyzed was approx 10k lines and printed to over 50 pages.   Yes, it was a single query.  I'm amazed that cognos would generate.  Basically they generate a pivoted cross-tab from sql.
>
> Thanks
> Doug
>
>
>
>
> -----Original Message-----
> From: Rob Sargent [mailto:robjsargent@gmail.com] 
> Sent: Wednesday, September 09, 2009 11:59 PM
> To: Little, Douglas
> Subject: Re: [SQL] how to: refer to select list calculations other places in the calculations.
>
> Would reverting to the base columns work?
>
> select a, b, a+b as c, (a+b)*d, (a+b)*f etc.
>
> Little, Douglas wrote:
>   
>> Hi,
>>
>> I have very complex sql (generated by cognos) I'm porting from 
>> Teradata that basically uses column alias in the calculated columns.
>>
>> Is there any way to do this type of thing in Psql?
>>
>> Essentially I need to do is refer to a calculated column later in the 
>> select list (but far more complex - like 50 pages printed out)
>>
>> sel a,b,a+b as c, c*d, c*f, c*g, c*h, c*I, c*j, c*k,...... --- where c is 
>> a calculated column used in other calculations.
>>
>> from ....
>>
>> **Doug Little**
>>
>> Sr. Data Warehouse Architect | Enterprise Data Management | Orbitz 
>> Worldwide
>>
>> 500 W. Madison, Suite 1000 Chicago IL 60661| Office 312.260.2588 | Fax 
>> 312.894.5164 | Cell 847-997-5741
>>
>>
>>       ***Douglas.Little@orbitz.com* <mailto:Douglas.Little@orbitz.com>**__
>>
>> orbitz.com <http://www.orbitz.com/; | ebookers.com 
>> <http://www.ebookers.com/; | hotelclub.com <http://www.hotelclub.com/; 
>> | cheaptickets.com <http://www.cheaptickets.com/; | ratestogo.com 
>> <http://www.ratestogo.com/; | asiahotels.com <http://www.asiahotels.com/;
>>
>>     



view thread (4+ messages)  latest in thread

Message-ID: <4AA92A28.1060902@gmail.com>
Permalink:  ../4AA92A28.1060902@gmail.com/
Also on:    postgresql.org/message-id/4AA92A28.1060902@gmail.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: robjsargent@gmail.com, DOUGLAS.LITTLE@orbitz.com
  Subject: Re: how to: refer to select list calculations other places in the calculations.
  In-Reply-To: <4AA92A28.1060902@gmail.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