hortensiam
IS-IT--Management
hi!,
I need two types of sums in the same query. One type of sum correspond to the -group by- selection and the other type of sum correspond to a general total- .
I think something like that:
SELECT especiali,partido,descrip,
sum( case when esp_dedi='E' then 1 else 0 end) as count_E,
sum( case when esp_dedi='D' then 1 else 0 end) as count_D
FROM MED_ESP INNER JOIN
ESPECIAL ON MED_ESP.ESPECIALI = ESPECIAL.CODIGO INNER JOIN PARTIDO ON MED_ESP.PARTIDO = PARTIdO.NROPARTIDO
group by
MED_ESP.especiali,
ESPECIAL.descripcio,
MED_ESP.partido
but i need the totals group by only for mes_esp.partido in the same query!!!!
I need two types of sums in the same query. One type of sum correspond to the -group by- selection and the other type of sum correspond to a general total- .
I think something like that:
SELECT especiali,partido,descrip,
sum( case when esp_dedi='E' then 1 else 0 end) as count_E,
sum( case when esp_dedi='D' then 1 else 0 end) as count_D
FROM MED_ESP INNER JOIN
ESPECIAL ON MED_ESP.ESPECIALI = ESPECIAL.CODIGO INNER JOIN PARTIDO ON MED_ESP.PARTIDO = PARTIdO.NROPARTIDO
group by
MED_ESP.especiali,
ESPECIAL.descripcio,
MED_ESP.partido
but i need the totals group by only for mes_esp.partido in the same query!!!!