More SQL Fun

I have two tables, one might be the traffic per month, the other one a
list of all computers.

| id | ip  | month | year | sum |


| id | ip | name |

Now I want to LEFT JOIN these on ip in only one row. But there is one
row in a for every ip and month. I’m only interested in the sum from
this and last month. So I want to LEFT JOIN multiple fits into one row:

SELECT b.ip AS ip, a1.sum AS this, a2.sum AS last
LEFT JOIN a AS a1 ON a1.ip=b.ip AND month=MONTH(NOW())
LEFT JOIN a AS a2 ON a2.ip=b.ip AND month=((MONTH(NOW())+10)%12)+1
WHERE ip=""

Now say, that there is no entry for last month. last would be
NULL. But our sourcecode for some reason doesn’t like NULL entries. So
I want to avoid NULL when doing a LEFT JOIN:

IFNULL(a2.sum,'0') AS last