Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/11/2016, 15:16
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Select agrupado y con fecha mayor

Código SQL:
Ver original
  1. SELECT t1.* FROM clientes AS t1
  2. LEFT JOIN (SELECT MAX(fecha) AS fecha, id_cliente, tipo FROM clientes GROUP BY id_cliente, tipo) AS t2 ON (t1.id_cliente=t2.id_cliente AND t1.fecha=t2.fecha AND t1.tipo=t2.tipo)
  3. WHERE t1.tipo='A'

Algo como eso ;)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me