Nested select - Mailing list pgsql-sql

From Hubert Retif
Subject Nested select
Date
Msg-id 200611061136.kA6BahZc012041@saturn11.saturn11.de
Whole thread Raw
Responses Re: Nested select
Re: Nested select
Re: Nested select
Re: Nested select
List pgsql-sql

Hi,

 

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

 

Has someone a solution for that situation?

 

Thanks,

Hubert Retif

pgsql-sql by date:

Previous
From: "Anonymous"
Date:
Subject: Re: Function to reset sequence.....
Next
From: imad
Date:
Subject: Re: Nested select