you did not explain what the datetable is for, and it appears you have two different history tables
plus, you say you posted a "simplified" version of your query
so i'm not gonna try to rework what you have, i'll just give you some pseudo-code and you can take it from there
first, you can simulate a full outer join with a UNION, and then you can join the summed-up results of the union to some other table...
Code:
SELECT keycolumns
, SUM(this_month) AS this_month
, SUM(last_month) AS last_month
FROM ( SELECT keycolumns
, datacolumn AS this_month
, 0 AS last_month
FROM daTable
WHERE conditions_for_this_month
UNION ALL
SELECT keycolumns
, 0 AS this_month
, datacolumn AS last_month
FROM daTable
WHERE conditions_for_last_month
) AS data
INNER
JOIN someothertable
ON someothertable.columns = data.keycolumns
helps?
