seria algo asi:
Código SQL:
Ver originalSELECT
CASE
WHEN mes1>0 THEN COUNT(1) END AS total_mes1,
CASE
WHEN mes1>0 THEN SUM(mes1)END AS sum_mes1,
CASE
WHEN mes2>0 THEN COUNT(1) END AS total_mes2,
CASE
WHEN mes2>0 THEN SUM(mes1)END AS sum_mes2,
CASE
WHEN mes3>0 THEN COUNT(1) END AS total_mes3,
CASE
WHEN mes3>0 THEN SUM(mes1)END AS sum_mes3
FROM tabla GROUP BY mes1,mes2,mes3
Saludos!