Discarding results from CTE based on another CTE WITH R1 AS
(
    // some complex query
),
R2 AS 
(
    // uses R1
    // another complex query
),
// here I already have dataset with Id, Name, ProductReference and other columns
R3 AS 
(
    select  Name, ProductReference, Count(*) as Count  
    from Products 
    group by Name, ProductReference
    having Count(*) &gt; 1
)


Now I need to filter R2 results based on R3, so that if Name and Reference combinations ARE present in R2 then only select where ID is minimum, discard rest of them

R2
Id      Name        ProductReference    OtherColumns
1       n1          someguid1           some data
2       n1          someguid1           some data
3       n2          someguid2           some data
4       n3          someguid1           some data
5       n1          someguid1           some data
6       n1          someguid2           some data

R3
Id      Name        ProductReference    Count
1       n1          someguid1           4


Expected Output
Id      Name        ProductReference    OtherColumns
1       n1          someguid1           some data
3       n2          someguid2           some data
4       n3          someguid1           some data
if im not mistaken, you can get the result you want in R3, 
simply use

select min(id) as Id,Name,ProductReference
from Products
group by Name,ProductReference


the result will return exactly what you are looking for
in your example, n1 will be grouped to its minimum id, thus the result set will be


  Id,Name,PR,OC 
  1,n1,...,... 3,n2,...,... 4,n3,...,...