Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C28019FA7B6 for ; Mon, 6 Nov 2006 07:27:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87404-06 for ; Mon, 6 Nov 2006 07:27:46 -0400 (AST) X-Greylist: delayed 00:19:03.18215 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6740B9FA999 for ; Mon, 6 Nov 2006 07:27:46 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from saturn11.saturn11.de (saturn11.de [151.189.43.60]) by svr4.postgresql.org (Postfix) with ESMTP id 5D24C5AF884 for ; Mon, 6 Nov 2006 11:08:40 +0000 (GMT) Received: from HUBERTM70 (cable-static-75-124.intergga.ch [157.161.75.124]) by saturn11.saturn11.de (8.13.8/8.13.8/Sun Solaris 8.12.8-0.5) with ESMTP id kA6BahZc012041 for ; Mon, 6 Nov 2006 12:36:43 +0100 Message-Id: <200611061136.kA6BahZc012041@saturn11.saturn11.de> Reply-To: From: =?us-ascii?Q?Hubert_Retif?= To: Subject: Nested select Date: Mon, 6 Nov 2006 12:08:36 +0100 Organization: i-netSoft GmbH MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0003_01C7019C.4AFA92D0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AccBk2MlT9ehuboMSROfTHREdaMpkA== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/74 X-Sequence-Number: 26726 This is a multi-part message in MIME format. ------=_NextPart_000_0003_01C7019C.4AFA92D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0003_01C7019C.4AFA92D0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

------=_NextPart_000_0003_01C7019C.4AFA92D0--