Ver Mensaje Individual
  #21 (permalink)  
Antiguo 12/08/2008, 11:35
Avatar de flaviovich
flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 2.951
Antigüedad: 18 años, 9 meses
Puntos: 39
Respuesta: columnas dinamicas en select

A ver, he corregido tu query. Te recomiendo seguir de esta forma:
Código:
select distinct t2.v_usuario [Id_Usuario], t1.nombre [Nombre], t1.apellido1 [Apellido1], t1.apellido2 [Apellido2],
t2.v_curso_programado [Id_Curso_Programado],
case when t2.id_curso=212 then convert(nvarchar,t2.fecha_fin) else '' end [CIR], 
case when t2.id_curso=187 then convert(nvarchar,t2.fecha_fin) else '' end [CSIS],
case when t2.id_curso=175 then convert(nvarchar,t2.fecha_fin) else '' end [prueab],
case when t2.id_curso=207 then convert(nvarchar,t2.fecha_fin) else '' end [DGR8], 
case when t2.id_curso=51 then convert(nvarchar,t2.fecha_fin) else '' end [PRL],
case when t2.id_curso=235 then convert(nvarchar,t2.fecha_fin) else '' end [CER], 
case when t2.id_curso=232 then convert(nvarchar,t2.fecha_fin) else '' end [CCA],
case when t2.id_curso=258 then convert(nvarchar,t2.fecha_fin) else '' end [RCCA], 
case when t2.id_curso=205 then convert(nvarchar,t2.fecha_fin) else '' end [DGR10],
case when t2.id_curso=186 then convert(nvarchar,t2.fecha_fin) else '' end [DGR9], 
case when t2.id_curso=281 then convert(nvarchar,t2.fecha_fin) else '' end [CCR],
case when t2.id_curso=255 then convert(nvarchar,t2.fecha_fin) else '' end [CS]
from dbo.vista_temp t2
inner join gestion_usuarios.dbo.tusuarios t1 ON t2.v_usuario = t1.id_usuario 
group by t2.v_usuario,t2.v_curso_programado,t1.nombre,t1.apellido1,t1.apellido2,t2.fecha_fin,t2.id_curso
order by id_usuario
Ahora, que error te da?
Y una pregunta mas, para que conviertes tu fecha a cadena?
__________________
No repitamos temas, usemos el Motor de busquedas
Plantea bien tu problema: Ayúdanos a ayudarte.