Agrupar una autounión:
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
Véalo en sqlfiddle .
Agrupar una autounión:
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
Véalo en sqlfiddle .