Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/04/2012, 15:18
morkartremor
 
Fecha de Ingreso: septiembre-2008
Mensajes: 8
Antigüedad: 16 años, 2 meses
Puntos: 0
Información GROUP BY no me funciona

Antes que nada agradecer su ayuda, stoy corriendo un query donde solicito sub consultas dentro de otra consulta, en esta ultima le pido que me agrupe por persona el problema es que las subconsultas no se agrupan, me aparece la informacion dividida pero repetida es decir no agrupa la momento de aplicar la consulta gracias por su apoyo dejo el codigo de la consulta y una imagen de los resultados

Código HTML:
SELECT 

Evaluado, 

(select AVG("P1") from tbldatos where modulo='a') as [P1-MA],
(select AVG("P2") from tbldatos where modulo='a') as [P2-MA],
(select AVG("P3") from tbldatos where modulo='a') as [P3-MA],
(select AVG("P4") from tbldatos where modulo='a') as [P4-MA],
(select AVG("P5") from tbldatos where modulo='a') as [P5-MA],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='a') as [Prom-MA],

(select AVG("P1") from tbldatos where modulo='b') as [P1-MB],
(select AVG("P2") from tbldatos where modulo='b') as [P2-MB],
(select AVG("P3") from tbldatos where modulo='b') as [P3-MB],
(select AVG("P4") from tbldatos where modulo='b') as [P4-MB],
(select AVG("P5") from tbldatos where modulo='b') as [P5-MB],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='b') as [Prom-MB],

(select AVG("P1") from tbldatos where modulo='c') as [P1-MC],
(select AVG("P2") from tbldatos where modulo='c') as [P2-MC],
(select AVG("P3") from tbldatos where modulo='c') as [P3-MC],
(select AVG("P4") from tbldatos where modulo='c') as [P4-MC],
(select AVG("P5") from tbldatos where modulo='c') as [P5-MC],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='c') as [Prom-MC],

(select AVG("P1") from tbldatos where modulo='d') as [P1-MD],
(select AVG("P2") from tbldatos where modulo='d') as [P2-MD],
(select AVG("P3") from tbldatos where modulo='d') as [P3-MD],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='d') as [Prom-MD],

(select AVG("P1") from tbldatos where modulo='e') as [P1-ME],
(select AVG("P2") from tbldatos where modulo='e') as [P2-ME],
(select AVG("P3") from tbldatos where modulo='e') as [P3-ME],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='e') as [Prom-ME],

(select AVG("P1") from tbldatos where modulo='f') as [P1-MF],
(select AVG("P2") from tbldatos where modulo='f') as [P2-MF],
(select AVG("P3") from tbldatos where modulo='f') as [P3-MF],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='f') as [Prom-MF],

(select AVG("P1") from tbldatos where modulo='g') as [P1-MG],
(select AVG("P2") from tbldatos where modulo='g') as [P2-MG],
(select AVG("P3") from tbldatos where modulo='g') as [P3-MG],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='g') as [Prom-MG],

(select AVG("P1") from tbldatos where modulo='h') as [P1-MH],
(select AVG("P2") from tbldatos where modulo='h') as [P2-MH],
(select AVG("P3") from tbldatos where modulo='h') as [P3-MH],
(select AVG("P4") from tbldatos where modulo='h') as [P4-MH],
(select AVG("P5") from tbldatos where modulo='h') as [P5-MH],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='h') as [Prom-MH],

(select AVG("P1") from tbldatos where modulo='i') as [P1-MI],
(select AVG("P2") from tbldatos where modulo='i') as [P2-MI],
(select AVG("P3") from tbldatos where modulo='i') as [P3-MI],
(select AVG("P4") from tbldatos where modulo='i') as [P4-MI],
(select AVG("P5") from tbldatos where modulo='i') as [P5-MI],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='i') as [Prom-MI],

(select AVG("P1") from tbldatos where modulo='j') as [P1-MJ],
(select AVG("P2") from tbldatos where modulo='j') as [P2-MJ],
(select AVG("P3") from tbldatos where modulo='j') as [P3-MJ],
(select AVG("P4") from tbldatos where modulo='j') as [P4-MJ],
(select AVG("P5") from tbldatos where modulo='j') as [P5-MJ],
(select (AVG("P1")+AVG("P2")+AVG("P3")+AVG("P4")+AVG("P5"))/5 from tbldatos where modulo='j') as [Prom-MJ]

FROM tbldatos

WHERE 
empresa='gho'

GROUP BY 
Evaluado

ORDER BY 
Evaluado
el resultado es :



Espero me puedan ayudar muchas gracias !!!