Ver Mensaje Individual
  #10 (permalink)  
Antiguo 10/06/2013, 12:21
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 3 meses
Puntos: 774
Respuesta: me ayudan con la 2° parte de este query?

Código SQL:
Ver original
  1. WITH AllActivities
  2. AS
  3. (
  4. SELECT
  5.             ACTIVITY_NAME AS ACTIVIDAD, TO_CHAR(TRUNC(t.CREATION_TIME, 'HH'), 'DD-MON-YYYY HH24:MI:SS') AS HORA,
  6.             COUNT (*) AS CANTIDAD
  7.  
  8. FROM DB2USER.TASKS t
  9.  
  10. WHERE t.CREATION_TIME> TO_DATE ('04-JUN-2013', 'dd - mon - yyyy')
  11. AND t.CREATION_TIME< TO_DATE ('05-JUN-2013', 'dd - mon - yyyy')
  12. AND t.BPD_NAME = 'CILI - Control Instrumental'
  13. AND t.ACTIVITY_NAME IS NOT NULL
  14.  
  15. GROUP BY ACTIVITY_NAME, TO_CHAR (TRUNC (t.CREATION_TIME, 'HH'), 'DD-MON-YYYY HH24:MI:SS')
  16. ORDER BY ACTIVITY_NAME, TO_CHAR (TRUNC (t.CREATION_TIME, 'HH'), 'DD-MON-YYYY HH24:MI:SS') ASC
  17. )
  18.  
  19.  
  20. SELECT AllActivities.actividad,total,g_total,CAST(total / CAST(g_total AS DECIMAL(10,4)) AS DECIMAL (10,4)) AS porce  FROM AllActivities    
  21. LEFT JOIN (SELECT SUM(total) g_total,horario FROM AllActivities GROUP BY horario) t1
  22. ON (t1.horario=AllActivities.horario)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me