X-Original-To: pgsql-general@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E3EC4768AA for ; Wed, 14 May 2003 10:50:35 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 34284-04 for ; Wed, 14 May 2003 10:50:30 -0400 (EDT) Received: from equinox.cdli.co.uk (unknown [80.6.93.1]) by postgresql.org (Postfix) with ESMTP id 1526F47675B for ; Wed, 14 May 2003 06:53:53 -0400 (EDT) Received: (from uucp@localhost) by equinox.cdli.co.uk (8.11.6+Sun/8.11.6) id h4EAqfb04072 for ; Wed, 14 May 2003 11:52:41 +0100 (BST) Received: from cdl-rl.cdli.co.uk(192.168.0.103) by equinox.cdli.co.uk via csmap (V6.0) id srcAAAwza48h; Wed, 14 May 03 11:52:41 +0100 Reply-To: From: "Rob Larter" To: Subject: query help Date: Wed, 14 May 2003 11:55:47 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Importance: Normal X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/444 X-Sequence-Number: 42099 hi i am trying to execute the following query: select source,(b.source/c.total),(select count(*) from entries b where source = a.source) as source,(select count(*) from entries c) as total from entries a group by source; it says ERROR: Relation "b" does not exist the query: select source,(select count(*) from entries where source = a.source) as source,(select count(*) from entries) as total from entries a group by source; works fine but i want to use the result from source and entries to work out a percentage in the sql query could someone point me in the right direction? Thanks! Rob