pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Help on Union Query
2+ messages / 2 participants
[nested] [flat]

* Re: Help on Union Query
@ 2000-10-24 22:06  Josh Berkus <josh@agliodbs.com>
  parent: Craig May <craig.may@s2.enthdimension.com.au>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2000-10-24 22:06 UTC (permalink / raw)
  To: pgsql-sql

Mr. May,

	The reason you're having trouble is that the problem you've described
does not call for a union query at all.  What you want is a simple GROUP
BY query:

SELECT Node_ID, Word, Count(*) 
FROM NodeIndex
GROUP BY Node_ID, Word

-Josh Berkus

-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 436-9166
   for law firms, small businesses       fax  436-0137
    and non-profit organizations.       pager 338-4078
                        		San Francisco



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Help on Union Query
@ 2000-10-25 04:44  Craig May <craig.may@s2.enthdimension.com.au>
  0 siblings, 1 reply; 2+ messages in thread

From: Craig May @ 2000-10-25 04:44 UTC (permalink / raw)
  To: 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-10-25 04:44 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-25 04:44 Help on Union Query Craig May <craig.may@s2.enthdimension.com.au>
2000-10-24 22:06 ` Josh Berkus <josh@agliodbs.com>

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