limiting the rows to where the sum a column equals a certain value
I think the problem could be due to the nested query being &gt;= and not =.

This gives the output you described:

SELECT t.id, t.volume, t.price,
(SELECT SUM(volume) FROM buy WHERE id = t.id) 'RequiredVolume'
FROM buy t
HAVING RequiredVolume &lt;= '1.5000'
ORDER BY price DESC, id ASC;


Memo - Can you please post what your expected results would be for all fields and not just the ID ordering.