Estimados.
Utilizo SS2000 SP4
Tengo una tabla llamada situaciones, la cual tiene:
Codigo_Cliente varchar(20)
tipositu Int
Puedo tener un Codigo_Cliente con diferente Tipo:
Codigo_Cliente Tipo
1234 1
1234 2
1235 1
Necesito una consulta que me devuelva:
Codigo_Cliente tipositu
1234 2
1235 1
Es decir, en caso de tener el tipositu =2 me debe seleccionar dicho
registro, si no lo tiene me muestra el registro de tipositu =1
Tengo esto:
Select Codigo_Cliente ,tipositu From ra_situ A
Where codcli='1234' and tipositu in(2,1)
and not exists
(
Select Codigo_Cliente ,tipositu From ra_situ b
Where Codigo_Cliente ='1234' and tipositu in(1)
and a.Codigo_Cliente =b.Codigo_Clienteand a.tipositu=b.tipositu
)
Pero claramente estoy errado. En algun momento lo hice con UNION pero
no es lo mas elegante :)
Atte.
Penta.
Leer las respuestas