simple ;)
Código SQL:
Ver originalSELECT DESC,SUM(grupo1), SUM(grupo2), SUM(grupo3), SUM(grupo4) FROM
(
SELECT
rt.[name] AS [DESC]
,CASE WHEN [crew] = 'Grupo 1' THEN ROUND(SUM(stat.[duration] / 3600),2)END AS Grupo1
,CASE WHEN [crew] = 'Grupo 2' THEN ROUND(SUM(stat.[duration] / 3600),2)END AS Grupo2
,CASE WHEN [crew] = 'Grupo 3' THEN ROUND(SUM(stat.[duration] / 3600),2)END AS Grupo3
,CASE WHEN [crew] = 'Grupo 4' THEN ROUND(SUM(stat.[duration] / 3600),2)END AS Grupo4
FROM [scmapview].[dbo].[hist_statusevents] stat
INNER JOIN [scmapview].[dbo].[hist_exproot] eroot
ON stat.shiftindex = eroot.shiftindex
INNER JOIN scmapview.dbo.hist_reasontable AS rt
ON stat.shiftindex = rt.shiftindex
AND stat.[STATUS] = rt.[STATUS]
AND stat.[category] = rt.[category]
AND stat.[reason] = rt.[reason]
WHERE [shiftdate] BETWEEN '2015-01-01' AND '2015-01-07'
AND stat.[STATUS] IN (4) AND [unit] = '1'
GROUP BY crew , rt.[name]
-- ORDER BY rt.[name]
) AS t1
GROUP BY DESC