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