Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/02/2013, 10:48
zubintro
 
Fecha de Ingreso: septiembre-2007
Mensajes: 120
Antigüedad: 17 años, 1 mes
Puntos: 0
Respuesta: agrupar valores similares dentro de una fila

Muchas gracias a los que me ayudaron con sus respuestas. Los dejo el codigo de como termine por agrupar los datos

Código:
SELECT        id_ev_pai, Alumno, Profesor, Escuela, Grado, Grupo, ID, 						
						
SUM(
	CASE WHEN R4 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R26 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R55 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R103 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R6 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R71 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R24 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R99 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R27 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R48 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R64 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R97 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R29 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R50 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R73 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R90 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R32 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R49 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R77 = 1 THEN 1 ELSE 0 END +
	CASE WHEN R88 = 1 THEN 1 ELSE 0 END
) as Poco_Logrado,					 
SUM (
	CASE WHEN R4 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R26 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R55 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R103 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R6 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R71 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R24 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R99 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R27 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R48 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R64 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R97 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R29 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R50 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R73 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R90 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R32 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R49 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R77 = 2 THEN 1 ELSE 0 END +
	CASE WHEN R88 = 2 THEN 1 ELSE 0 END
) as Medianamente_logrado,
SUM (
	CASE WHEN R4 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R26 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R55 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R103 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R6 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R71 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R24 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R99 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R27 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R48 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R64 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R97 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R29 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R50 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R73 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R90 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R32 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R49 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R77 = 3 THEN 1 ELSE 0 END +
	CASE WHEN R88 = 3 THEN 1 ELSE 0 END
) as Logrado,
SUM (
	CASE WHEN R4 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R26 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R55 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R103 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R6 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R71 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R24 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R99 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R27 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R48 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R64 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R97 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R29 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R50 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R73 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R90 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R32 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R49 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R77 = 4 THEN 1 ELSE 0 END +
	CASE WHEN R88 = 4 THEN 1 ELSE 0 END
) as Pendiente

FROM vw_ev_1ro
group by id_ev_pai, Alumno, Profesor, Escuela, Grado, Grupo, ID

Saludos y gracias nuevamente