Eric's antwoord is misschien een beetje verbeterd:
select
sp1.sid as sid1,
sp2.sid as sid2,
count(*) as num
from
sp as sp1
inner join sp as sp2 on sp1.pid=sp2.pid and sp1.sid<sp2.sid
group by sp1.sid, sp2.sid
;
Gebruik
Eric's antwoord is misschien een beetje verbeterd:
select
sp1.sid as sid1,
sp2.sid as sid2,
count(*) as num
from
sp as sp1
inner join sp as sp2 on sp1.pid=sp2.pid and sp1.sid<sp2.sid
group by sp1.sid, sp2.sid
;
Gebruik