Re: Correlated Subquery and calculated column non-functional - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Correlated Subquery and calculated column non-functional
Date
Msg-id 4AEB25A0.30407@iol.ie
Whole thread Raw
In response to Correlated Subquery and calculated column non-functional  (The Frog <mr.frog.to.you@googlemail.com>)
Responses Re: Correlated Subquery and calculated column non-functional
List pgsql-general
On 30/10/2009 10:07, The Frog wrote:
> select
>     product.manufacturer,
>     product.brand,
>     SUM(sales.qtysold * sales.unitprice) as turnover,
>     (select count(*) from cube_sales.sales as Q WHERE SUM(sales.qtysold *
> sales.unitprice) > turnover) + 1 as rank

You can't use the alias "turnover" in the calculation as you have - you
need to use the full expression instead, or push the calculation into a
subquery.

BTW you're also missing a closing parenthesis from that calculation.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: The Frog
Date:
Subject: Correlated Subquery and calculated column non-functional
Next
From: Richard Broersma
Date:
Subject: Re: Correlated Subquery and calculated column non-functional