Extract Unique Pairs from Table Containing Reciprocal Relationships
问题 Consider a SQL Server 2005 database with a bunch of data on a lot of people, a large chunk of whom are married . To track relationships among people, a Relationship table exists that serves to link the ID of one person to the ID of another. A Relationship Type on each Relationship record serves to indicates the type of relationship exists between the two people in question (duh): "is married to", "is son of", "is daughter of", etc. For married people, there are TWO relationship records in the