Erics svar kan vara lite bättre:
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
;
Använd
Erics svar kan vara lite bättre:
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
;
Använd