Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/10/2012, 17:25
ragde23fer
 
Fecha de Ingreso: octubre-2008
Mensajes: 268
Antigüedad: 15 años, 7 meses
Puntos: 3
Respuesta: Select a tabla cuyos datos no estan en otra tabla

Cita:
Iniciado por Libras Ver Mensaje
podrias hacer algo asi

select * from tabla1 as t1
left join tabla2 as t2 on (t1.id=t2.id)
where t2.id is null

asi sacas los que no tienen ninguna factura :)
Muy buen dato, acabo de sacarlo, pero me he complicado demasiado, tu solucion es mejor

SELECT
C.COD_CLIENTE,
C.NOM_CLIENTE,
COUNT(C.COD_CLIENTE) AS CANTIDAD
FROM
CLIENTE C, FACTURA F
WHERE
C.COD_CLIENTE != F.COD_CLIENTE
GROUP BY C.COD_CLIENTE, C.NOM_CLIENTE
HAVING COUNT(C.COD_CLIENTE) > (SELECT COUNT(*) FROM FACTURA)-1
ORDER BY C.COD_CLIENTE