我很難找到一個好問題標題 - 讓我告訴你我有什麼以及期望的結果。我希望這可以在SQL中完成(我有SQL Server 2008)。可以返回相交數據的SQL查詢
1)我有一個表叫Contacts
並在該表中我有這樣的領域:
FirstName, LastName, CompanyName
2)一些演示數據:
FirstName LastName CompanyName
John Smith Smith Corp
Paul Wade
Marc Andrews Microsoft
Bill Gates Microsoft
Steve Gibbs Smith Corp
Diane Rowe ABC Inc.
3)我想要得到的交人員和公司名單,但公司只有一次。這看起來像這樣:
Name
ABC Inc.
Bill Gates
Diane Rowe
John Smith
Marc Andrews
Microsoft
Smith Corp
Steve Gibbs
Paul Wade
我可以用SQL來做這個嗎?怎麼樣?
有趣的是,每個人的細微差別都有相同的答案。 – 2010-06-12 18:29:38