Tema: Subconsulta?
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/09/2017, 10:03
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 3 meses
Puntos: 774
Respuesta: Subconsulta?

My fault:

Código SQL:
Ver original
  1. SELECT t1.REF,t1.elem FROM #temp AS t1
  2. LEFT JOIN(
  3. SELECT REF FROM #temp GROUP BY REF  HAVING COUNT(*) < 2) AS t2 ON (t1.REF=t2.REF)
  4. WHERE t2.REF IS NOT NULL

Se me paso quitar los null del left join o si usamos inner join:

Código SQL:
Ver original
  1. SELECT t1.REF,t1.elem FROM #temp AS t1
  2. INNER JOIN(
  3. SELECT REF FROM #temp GROUP BY REF  HAVING COUNT(*) < 2) AS t2 ON (t1.REF=t2.REF)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me