by Nathan
25. July 2011 07:20
There are various ways to find duplicates in sql server.
Here are some example SQL Codes for it.
select count(*),description, min(entrytime) as firstbet ,max(entrytime) as lastrecord,
datediff(s,min(entrytime),max(entrytime)) as secondsapart
from mytable with(nolock)
where 1=1
group by description
having count(*) > 2
if more than one record you will need to add more columns to the group by statement
select count(*),firstname,lastname, min(datecreated) as firstbet ,
max(datecreated) as lastrecord,
datediff(s,min(datecreated),max(datecreated)) as secondsapart
from mytable with(nolock)
where 1=1
and datecreated > GETDATE()-130
group by firstname,lastname
having count(*) > 2
the next step is to remove duplicates here is how it can be done...
1cb53329-1640-4476-bcf0-49ab4c507d73|0|.0
Tags: SQL
SQL