Ver Mensaje Individual
  #4  
Antiguo 26-05-2008
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.293
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Suponiendo que los rellenes en orden, esto podría funcionar:

Código SQL [-]
select * from (SELECT historico.idcliente, Count(historico.tipo) as ctipo
FROM historico
GROUP BY historico.idcliente) where ctipo=1

Y esto supongo que también

Código SQL [-]
select * FROM historico as hist2 where hist2.idcliente not in(
SELECT idcliente FROM historico where tipo='ul')


De todas formas decir que ambas consulta no son muy eficientes. Creo que no es problema de la consulta, sino un problema de diseño.
No se si estás a tiempo de corregirlo, pero lo lógico sería no insertar un segundo registro con el mismo idCliente, sino actualizar el existente con el nuevo tipo.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita