I have a table as follows.
PersonId FriendId
p1 f1
p1 f2
p2 f1
p2 f3
p3 f1
p4 f1
p4 f2
I need to get all the people (PersonId) who have exactly (f1 and f2, for example. Could be any number of friends) as friends. What would be a good sql for this? In the above example, i need to get the answer as
PersonId
p1
p4