且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在SQL Server表中找到重复值?

更新时间:2023-01-22 09:14:30

我看到的第一个问题是你数不到1;重复意味着大于1.



其次,由于这是家庭作业,我只会指出你正确的方向。下面的查询基于您的查询并检查重复的名称。



The first problem I see is you are counting less than 1; duplicates mean greater than 1.

Secondly, since this is homework, I'll only point you in the right direction. The query below is based off of yours and checks for duplicate names.

SELECT (StudentFName + ' ' + StudentMName + ' ' + StudentLName) AS Name, 
	COUNT((StudentFName + ' ' + StudentMName + ' ' + StudentLName)) AS NumberOfNames
FROM tblStudentAdmission_basic
GROUP BY StudentFName, StudentMName, StudentLName
HAVING (COUNT((StudentFName + ' ' + StudentMName + ' ' + StudentLName)) > 1)