Definitivamente la solución son subconsultas.
A mi se me ocurrió algo similar
Código SQL:
Ver originalSELECT
t.estado,
SUM(COALESCE(t.valor,0)) AS suma_definitiva
FROM
(
SELECT
e.est_002 AS estado,
e.reg_001,
e.est_001,
a.agri04_001 AS ano,
a.agri04_005 AS valor
FROM estado e
LEFT JOIN
agri04 a
ON
(e.reg_001,e.est_001)=(a.reg_001,a.est_001)
) AS t
WHERE t.ano = '2005'
GROUP BY t.estado;
EDITO
o así
Código SQL:
Ver originalSELECT
t.estado,
SUM(COALESCE(t.valor,0)) AS suma_definitiva
FROM
(
SELECT
e.est_002 AS estado,
e.reg_001,
e.est_001,
a.agri04_001 AS ano,
a.agri04_005 AS valor
FROM estado e
LEFT JOIN
agri04 a
ON
(e.reg_001,e.est_001)=(a.reg_001,a.est_001)
) AS t
GROUP BY t.estado
HAVING t.ano = '2005';
No tengo como probarla.