我需要运行一个select语句,返回列的值不相同的所有行(例如EmailAddress).
例如,如果表格如下所示:
CustomerName EmailAddress
Aaron aaron@gmail.com
Christy aaron@gmail.com
Jason jason@gmail.com
Eric eric@gmail.com
John aaron@gmail.com
Run Code Online (Sandbox Code Playgroud)
我需要查询返回:
Aaron aaron@gmail.com
Christy aaron@gmail.com
John aaron@gmail.com
Run Code Online (Sandbox Code Playgroud)
我阅读了很多帖子并尝试了不同的查询无济于事.我认为应该工作的查询如下.有人可以提出替代方案或告诉我查询可能有什么问题吗?
select EmailAddress, CustomerName from Customers
group by EmailAddress, CustomerName
having COUNT(distinct(EmailAddress)) > 1
Run Code Online (Sandbox Code Playgroud)