nice job providing the sample data!
in this case, you need to get the "sets" organized first so they can be compared.
Someone else may have another method, but i thought using FOR XML to create a comma delimtied list would work fine.
select distinct T1.worker_id,AllRateCodes.Codez from #worker_rate T1
cross apply (SELECT Codez = STUFF((SELECT ',' + T2.rate_code
from #worker_rate T2
where T1.worker_id = T2.worker_id
ORDER BY rate_code
FOR XML PATH('')),1,1,'')) AllRateCodes
now that that is organized, I'm not sure if you need more than that, since it's visualized, ort if you need to join that resultset agaisnt itself so you can compare them?
i'm ASSUMING workerid is integers here really so i can order by and prevent duplicates(ie 1=2 and 2=1, which is repetitively redundant)
With MyCTE
AS
(
select distinct T1.worker_id,AllRateCodes.Codez from #worker_rate T1
cross apply (SELECT Codez = STUFF((SELECT ',' + T2.rate_code
from #worker_rate T2
where T1.worker_id = T2.worker_id
ORDER BY rate_code
FOR XML PATH('')),1,1,'')) AllRateCodes
)
SELECT * FROM MYCTE T1 INNER JOIN MyCTE T2
ON T1.Codez = T2.Codez
WHERE T1.worker_id <> T2.worker_id
AND T1.worker_id < T2.worker_id
Lowell