Raggruppa un self-join:
SELECT a.uid a, b.uid b, COUNT(*) cnt
FROM my_table a JOIN my_table b ON b.id = a.id AND b.uid > a.uid
GROUP BY a.uid, b.uid
Guardalo su sqlfiddle .
Raggruppa un self-join:
SELECT a.uid a, b.uid b, COUNT(*) cnt
FROM my_table a JOIN my_table b ON b.id = a.id AND b.uid > a.uid
GROUP BY a.uid, b.uid
Guardalo su sqlfiddle .