Hi im new to sql server 2005 and i have a big problem.
i want to delete a record having the same name and surname
Here is my table named Students
StudID FirstName LastName
1 Erwin Lopez
2 Archie Lopez
3 Lobanz Lopez
4 Erwin Lopez
5 Chie Lopez
6 Erwin Lopez
7 Lobanz Lopez
8 Erwin Lopez
Here's the catch i want to delete entry that has same firstname and lastname
but assuming that i dont know what is the firstname i just want to delete duplicating
entry if ever a user entered a same firstname and lastname
i tried distinct but im having a hard time please help me guys =(
here is my sample:
DELETE FROM Students WHERE FirstName NOT IN
(SELECT DISTINCT FirstName FROM Students GROUP BY StudID, FirstName, LastName)
-- i thought that every entry that is not in the distinct will be deleted im kinda confuse please help