mysql selecting a distinct summed column while having
If I understand correctly and you only want DISTINCT b values, you just need to remove the a column from the SELECT list and use SELECT DISTINCT:

SELECT DISTINCT
    t1.b - sum(t2.b) AS b
FROM
    t1 INNER JOIN t2 USING (id)
GROUP BY
    t1.id, t1.a, t1.b
HAVING
    t1.a - sum(t2.a) &gt; 0
ORDER BY
    b ASC
LIMIT 
    15 ;