none
Ajuda para somar resultados agrupados RRS feed

  • Discussão Geral

  • Pessoal tenho o seguinte resultado da minha tabela após executar a seguinte query:

    SELECT APPL_NAME, APPL_GEN_NO, START_DATE_TIME, END_DATE_TIME,
      DATEDIFF(SS, MIN (START_DATE_TIME), MIN (END_DATE_TIME)) AS DURACAO,
      DATEDIFF(SS, MIN (START_DATE_TIME), MIN (END_DATE_TIME)) / 3600 AS HORAS,
      (DATEDIFF(SS, MIN (START_DATE_TIME), MIN (END_DATE_TIME)) / 60) % 60 AS MINUTOS,
      DATEDIFF(SS, MIN (START_DATE_TIME), MIN (END_DATE_TIME)) % 60 AS SEGUNDOS
    from V_APPLICATION
    where APPL_NAME LIKE ISNULL(@Appl + '%', APPL_NAME)
    and START_DATE_TIME IS NOT NULL
    and START_DATE_TIME between @Inicio and @Fim
    group by APPL_NAME, APPL_GEN_NO, START_DATE_TIME, END_DATE_TIME
    order by APPL_NAME, START_DATE_TIME, DURACAO

    Resultado parcial:

    APPL_NAME APPL_GEN_NO START_DATE_TIME END_DATE_TIME DU  HO   MI     SEG

    BIG_APPL 1 2014-04-25 17:35:40.440 2014-04-25 17:36:09.170 29 0 0 29
    BIG_APPL 2 2014-04-25 17:36:24.540 2014-04-25 17:37:06.200 42 0 0 42
    BIG_APPL 3 2014-04-26 11:15:00.210 2014-04-26 11:29:34.150 874 0 14 34
    BIG_APPL 4 2014-04-26 12:15:00.510 2014-04-26 12:29:34.350 874 0 14 34
    BIG_APPL 5 2014-04-26 13:15:00.440 2014-04-26 13:29:33.960 873 0 14 33
    BIG_APPL 6 2014-04-26 14:15:00.250 2014-04-26 14:29:34.070 874 0 14 34
    BIG_APPL 7 2014-04-26 15:15:00.390 2014-04-26 15:29:34.220 874 0 14 34
    BIG_APPL 8 2014-04-26 16:15:00.450 2014-04-26 16:29:34.070 874 0 14 34

    Gostaria de somar as colunas finais resultantes dos cálculos de DATEDIFF (DURACAO, HORAS, MINUTOS e SEGUNDOS) agrupadas por APPL_NAME.

    Alguém poderia me ajudar.

    De ante mão agradeço.


    Aloysio Coutinho

    terça-feira, 13 de maio de 2014 18:50

Todas as Respostas