My fault:
Código SQL:
Ver originalSELECT t1.REF,t1.elem FROM #temp AS t1
LEFT JOIN(
SELECT REF FROM #temp GROUP BY REF HAVING COUNT(*) < 2) AS t2 ON (t1.REF=t2.REF)
WHERE t2.REF IS NOT NULL
Se me paso quitar los null del left join o si usamos inner join:
Código SQL:
Ver originalSELECT t1.REF,t1.elem FROM #temp AS t1
INNER JOIN(
SELECT REF FROM #temp GROUP BY REF HAVING COUNT(*) < 2) AS t2 ON (t1.REF=t2.REF)