A resposta de Eric pode ser um pouco melhorada:
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
;
Use para evitar obter (1,4,2) AND (4,1,2)