Help on Union Query

From: Craig May <craig(dot)may(at)s2(dot)enthdimension(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Help on Union Query
Date: 2000-10-25 04:44:50
Message-ID: 20001025044450.A6123@s2.enthdimension.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Carolyn Lu Wong 2000-10-25 05:03:10 quote in function
Previous Message Brian C. Doyle 2000-10-24 23:00:48 Re: Alternate Database Locations