View Single Post

   
  #1 (permalink)  
Old 04-09-2008, 05:48 PM
Andrej Kastrin
 
Posts: n/a
Default How to count pairs?

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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Reply With Quote