I can't rival the other guys on this board, but I am using this as practice for myself and would like (constructive but friendly) feedback on the solution I came up with if anyone is willing. 🙂
WITH CTE1 AS
(
SELECT IPCode, ID
FROM [Profile]
GROUP BY IPCode, ID
),
CTE2 AS
(
SELECT IPCode
FROM CTE1
GROUP BY IPCode
HAVING COUNT(*) > 1
)
SELECT IPCode, ID
FROM [Profile]
WHERE IPCode IN
(SELECT IPCode FROM CTE2)
GROUP BY IPCode, ID