I have a table of clients in SQL Server. I'm trying to find away to find duplicates in the email_address column, but I need to only consider part of the column data, so a substring. In practical terms I need to find duplicate domain names in the records.
I have used the following query to find exact duplicates (on the whole field), but how can I modify this to consider a substring?
SELECT a.email_address, b.dupeCount, a.client_id
FROM tblClient a
INNER JOIN (
SELECT email_address, COUNT(*) AS dupeCount
FROM tblClient
GROUP BY email_address
HAVING COUNT(*) > 1
) b ON a.email_address = b.email_address
Many thanks!