I have a sql server 2008 db and focussed on two specific columns in a table of over 300 million records. I wanted to find duplicate records which the table has but disinguish from this result set how many and if any of the duplicates have a different field 2.
eg.
field 1: idUrl
field 2: assignedId
so for duplicates of course:
SELECT [idUrl]
,[assignedId]
FROM [Feeds].[dbo].[LogFeed]
group by idUrl, assignedId
having COUNT(entryId) > 1
order by entryid desc
So I want to find records where for any duplicates of idUrl are there any records where assignedId is not the same for the duplicate idUrls.
eg
idUrl assignedID
www.google.com 10
www.google.com 10
www.google.com 10
www.google.com 7
we can write in so many ways i am giving the sample try this one
DECLARE @table table (idUrl varchar(100),assignedID int)
INSERT INTO @table
values(‘www.google.com’, 10),
(‘www.google.com’, 10),
(‘www.google.com’ , 10),
(‘www.google.com’ , 7)