Estimados.
Utilizo SS2000 SP4
Tengo una tabla llamada clientes que contiene:
cod_cliente, ano
supongamos:
cod_cliente, ano
1234 2008
5555 2008
1234 2009
Quisiera como resultado:
1234,2008,'Existe'
5555,2008,'No Existe'
Donde el tercer campo es el resultado de determinar si existe dhico
cod_cliente en el año 2009
Momentanamente lo hice con Exists y No exists y aplique UNION pero
quisera saber como poder hacerlo sin unir ambas consultas.
Select distinct cod_cliente,ano,'EXISTE en 2009'
From CLIENTES H
Where ano 08
and exists
(
Select * From clientes HH
Where ano 09
and h.cod_cliente=hh.cod_cliente
)
UNION
Select distinct cod_cliente,ano,'NO existe en 2009'
From CLIENTES H
Where ano 08
and not exists
(
Select * From clientes HH
Where ano 09
and h.cod_cliente=hh.cod_cliente
)
Atte.
PENTA.
Leer las respuestas