Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i can not find duplicate value in a table

What I have tried:

SELECT (StudentFName+' '+StudentMName+' '+StudentLName)as Name,FatherName,CONVERT(varchar(20),DOB,103)AS DOB,COUNT(*) TotalCount
FROM tblStudentAdmission_basic
GROUP BY StudentFName,StudentMName,StudentLName,FatherName,DOB
HAVING COUNT(*) < 1
ORDER BY COUNT(*) DESC
Posted
Updated 7-Nov-16 19:46pm
v2
Comments
Animesh Datta 8-Nov-16 1:40am    
if duplicate value exists then count(*)> 1 not count(*)<1
Ubais Khan 8-Nov-16 2:03am    
thanks

1 solution

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.

C#
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)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900