Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2B0149FA103 for ; Mon, 6 Nov 2006 15:07:20 -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 19999-04 for ; Mon, 6 Nov 2006 15:07:13 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by postgresql.org (Postfix) with ESMTP id 1B6F19FA136 for ; Mon, 6 Nov 2006 15:07:12 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id c2so822163nfe for ; Mon, 06 Nov 2006 11:07:11 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=f22Fkkw/4ctFsdQIm+xLiD98uNhRdk8kE46cfJQ033oa1JhMQA+ZGdc6dSMPDePC3WQLE3haRixwdZ56DYD6fOvZg70VP0SLaXfpKcufNNDNR/YMckePr4cmZbbf3z5oP/C1Se8maBPgtMZ06a0SbPXJOM5CCXtyDNblc2vR54c= Received: by 10.82.107.15 with SMTP id f15mr1352458buc.1162840030768; Mon, 06 Nov 2006 11:07:10 -0800 (PST) Received: by 10.82.161.3 with HTTP; Mon, 6 Nov 2006 11:07:10 -0800 (PST) Message-ID: <1f30b80c0611061107t48905e61jb975ffcbd2d1b34b@mail.gmail.com> Date: Tue, 7 Nov 2006 00:07:10 +0500 From: imad To: hubert.retif@i-netsoft.ch Subject: Re: Nested select Cc: pgsql-sql@postgresql.org In-Reply-To: <200611061136.kA6BahZc012041@saturn11.saturn11.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200611061136.kA6BahZc012041@saturn11.saturn11.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/75 X-Sequence-Number: 26727 Can you write the error message here? --Imad www.EnterpriseDB.com On 11/6/06, Hubert Retif wrote: > > > > > 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