使用选择查询在表中重复检查

时间:2019-07-17 15:19:07

标签: sql-server stored-procedures duplicates

以下查询是基于FirstName, LastName, PhoneNo的重复检查,它对我不起作用,因为我未在分组中包含“状态”列。因此,我想在返回结果中也将这些结果(Emp_Id, PostCode, and State)与这些结果一起包括在此字段中,仅对3列(名字,姓氏,电话号码)进行重复检查。你能帮助我吗?

select Distinct FirstName, LastName,PhoneNo from TestEmployee;

enter image description here

1 个答案:

答案 0 :(得分:1)

期待这个吗?

 SELECT DISTINCT MIN(emp_id) AS emp_id, FirstName, LastName, max(postcode) AS postcode, [State],PhoneNo FROM Employees
 GROUP BY FirstName, LastName,[State],PhoneNo