Hi all, here's some background on my question: an account can have multiple people in it, but a person can have multiple accounts (and share those accounts with people not in his other accounts - I hope I'm making sense).So say I have:SELECT 11 AS c_id, 102 AS acct_idINTO #sample_accountsUNION SELECT 12, 102UNION SELECT 14, 102UNION SELECT 11, 101UNION SELECT 12, 101UNION SELECT 13, 103UNION SELECT 14, 103UNION SELECT 21, 201UNION SELECT 22, 201--DROP TABLE #sample_accounts
I want to have a way that would show me that customers 11, 12, 13, and 14 are associated with each other but not with customers 21 and 22. Ideally I'd like the output to look like:c_id acct_id (it doesn't matter which account, so long as it's consistent)================11 10212 10213 10214 10221 20122 201
Any thoughts? I'm trying to figure out a way to do this without having to do a million self joins, but will be flexible enough to allow for multiple degrees of separation between customers.Thanks! x 10^6