pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hubert Retif <hubert.retif@i-netsoft.ch>
To: pgsql-sql@postgresql.org
Subject: Nested select
Date: Mon, 6 Nov 2006 12:08:36 +0100
Message-ID: <200611061136.kA6BahZc012041@saturn11.saturn11.de> (raw)

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

view thread (5+ messages)  latest in thread

Message-ID: <200611061136.kA6BahZc012041@saturn11.saturn11.de>
Permalink:  ../200611061136.kA6BahZc012041@saturn11.saturn11.de/
Also on:    postgresql.org/message-id/200611061136.kA6BahZc012041@saturn11.saturn11.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hubert.retif@i-netsoft.ch
  Subject: Re: Nested select
  In-Reply-To: <200611061136.kA6BahZc012041@saturn11.saturn11.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox