How to count pairs?

From: Andrej Kastrin <andrej(dot)kastrin(at)siol(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: How to count pairs?
Date: 2007-06-10 11:41:27
Message-ID: 466BE367.9020500@siol.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear all,

I need to count all pairs of instances which occure under given ID
number, e.g.:

ID word
-------------
1 car
1 fruit
2 car
2 fruit
2 vegetable
3 car
3 vegetable

And the output should be simillar to:

car fruit 2
car vegetable 2
fruit vegetable 1

Any suggestion how to do that in PgSQL? Thanks in advance for any pointers.

Cheers, Andrej

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-06-10 12:21:35 Re: How to count pairs?
Previous Message ABHANG RANE 2007-06-09 23:40:05 gist index on cube column