Que tal amigos, necesito hacer una consulta pero no me sale, el caso seria este:
Tabla
|PLANTILLA |CLAVE |R |C |VALOR
|Plantilla a |10Seccion1 |5 |2 |MANTENIMIENTO
|Plantilla a |10Seccion1 |2 |4 |29/07/2006
|Plantilla a |11Seccion1 |5 |2 |CAPACITACION
|Plantilla a |11Seccion1 |2 |4 |29/08/2006
|Plantilla a |12Seccion1 |5 |2 |ASESORIAS
|Plantilla a |12Seccion1 |2 |4 |29/09/2006
|Plantilla a |10Seccion1 |5 |2 |MANTENIMIENTO
|Plantilla a |10Seccion1 |2 |4 |29/10/2006
Lo que quiero hacer es seleccionar los valores sin repetir del campo VALOR(lo que es MANTENIMIENTO, ASESORIAS, etc.), pero condicionando que el año, que esta en otra fila de la tabla y que sea de la misma CLAVE, corresponda a uno q yo le determine, no se si me explique, quise hacer esto:
Código HTML:
select distinct valor from Tabla
where valor in (Select valor from Table where
CLAVE like '%Seccion1' and R='5' and C='2'
and plantilla='Plantilla a'
and valor in (Select valor from Tabla
where CLAVE like '%Seccion1'
and R='2' and C='4'
and plantilla='Plantilla a' and valor like '%2006'))
No se si me explique, si no es asi diganmelo y tratare de plantearlo mejor...