Received: from hub.org.org (localhost [127.0.0.1]) by hub.org (8.10.1/8.11.0) with SMTP id e9OKmNN58168 for ; Tue, 24 Oct 2000 16:48:25 -0400 (EDT) (envelope-from pgsql-sql-owner@hub.org) Received: from s2.enthdimension.com.au (IDENT:root@[203.36.78.178]) by hub.org (8.10.1/8.11.0) with ESMTP id e9OHkgN33990 for ; Tue, 24 Oct 2000 13:46:43 -0400 (EDT) (envelope-from root@s2.enthdimension.com.au) Received: (from root@localhost) by s2.enthdimension.com.au (8.9.3/8.8.7) id EAA06160 for pgsql-sql@postgresql.org; Wed, 25 Oct 2000 04:44:50 GMT Date: Wed, 25 Oct 2000 04:44:50 +0000 From: Craig May To: pgsql-sql@postgresql.org Subject: Help on Union Query Message-ID: <20001025044450.A6123@s2.enthdimension.com.au> Reply-To: craig.may@s2.enthdimension.com.au Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Mailer: Balsa 0.8.0 X-Archive-Number: 200010/212 X-Sequence-Number: 1874 Hi, I have an Index table with the following structure: | Node_ID (int) | Word (varchar)| and attempting to perform a query that returns the distinct Node_ID for an occurence of [word] in addition to a count of that [word] within the Node_ID. Here is the query I have atm: select distinct on (Node_ID) Node_ID from NodeIndex where word='[a word]' union select count(*) from NodeIndex where Node_ID in (select distinct on (Node_ID) Node_ID from NodeIndex where word='[a word]') order by count; Any assistance would be appreciated. Craig May Enth Dimension http://www.enthdimension.com.au