Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/05/2010, 09:24
newcomeralmeida
 
Fecha de Ingreso: junio-2009
Ubicación: chorrillos lima
Mensajes: 28
Antigüedad: 14 años, 11 meses
Puntos: 0
Pregunta subconsultas con case y exists

hola amigos tengo el siguiente query
declare @codigo as varchar(10)
declare @inicio as int
declare @final as int
set @codigo='ofi003'
set @inicio=7
set @final=10

SELECT c.tip_conc,(CASE WHEN tip_conc='OFICINA' THEN
(SELECT a.tip_conc,b.nom_ofic FROM A10_ALDISTRIBUCIONCATS as a,
A10_OFICINAS as b where a.cod_ofic=b.cod_ofic and a.ca1_cahi>=@inicio and ca1_cahi<=@final
group by a.cod_ofic,a.tip_conc,b.nom_ofic) ELSE
(SELECT a.tip_conc,b.mat_corr+' '+b.nom_corr as nombre,b.desc_corr as razon from A10_ALDISTRIBUCIONCATS AS a,
A10_VECORREDOR AS b WHERE a.cod_ofic=b.cod_corr and a.ca1_cahi>=@inicio and ca1_cahi<=@final
group by a.cod_ofic,a.tip_conc,b.mat_corr,b.nom_corr,b.desc _corr)
END) FROM A10_ALDISTRIBUCIONCATS as c WHERE c.cod_ofic=@codigo and c.ca1_cahi=@inicio and c.ca1_cahi=@final

al ejecutar las subconsultas por separado arroja datos
pero al ejecutar todo junto me sale el siguiente error

Sólo se puede especificar una expresión en la lista de selección cuando la subconsulta no se especifica con EXISTS