From: | "Aaron Bono" <postgresql(at)aranya(dot)com> |
---|---|
To: | hubert(dot)retif(at)i-netsoft(dot)ch |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Nested select |
Date: | 2006-11-07 14:40:38 |
Message-ID: | bf05e51c0611070640q15f4b519jf6ababf5c439f1b0@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 11/6/06, Hubert Retif <hubert(dot)retif(at)i-netsoft(dot)ch> wrote:
>
> I am migrating my application from MySQL to Postgresql and have met
> following situation:
>
>
>
> SELECT
>
> (sum(sold_price)/(select sum(sold_price) from car_archive))*100 as
> CA_pcent,
>
> reason_text
>
> FROM car_archive
>
> group by reason_text
>
> order by CA_pcent desc
>
>
>
> works perfectly in MySQL, but not in Postgresql. The problem seems to be
> the nested select which should deliver a sum of the whole table, but it does
> not.
>
>
>
> If I replace this nested select with a fix value, then it works:
>
>
>
> SELECT
>
> (sum(sold_price)/(333))*100 as CA_pcent,
>
> reason_text
>
> FROM car_archive
>
> group by reason_text
>
> order by CA_pcent desc
>
Are you suffering from round off error? That is the only thing I can think
of from what you have said.
What happens if you cast the price to a real or double precision?
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
From | Date | Subject | |
---|---|---|---|
Next Message | Aaron Bono | 2006-11-07 14:59:08 | Re: Distribution of results |
Previous Message | Jonah H. Harris | 2006-11-07 12:32:03 | Re: writing a simple sql parser and database program |