Search Postgresql Archives

Re: Correlated Subquery and calculated column non-functional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux