SELECT budget_id,
SUM(IF(type = 'allocation', points, 0)) AS allocated,
SUM(IF(type = 'issue', points, 0)) AS issued
FROM transactions
GROUP BY budget_id
SELECT budget_id,
SUM(IF(type = 'allocation', points, 0)) AS allocated,
SUM(IF(type = 'issue', points, 0)) AS issued
FROM transactions
GROUP BY budget_id