select x.id, x.value1, sum(y.value2), x.value1 - sum(y.value2)
inner join y
on x.id = y.idx
Having the subquery in the SELECT caluse, as you have done it, would probably have the subquery execute for every record returned and therefore would be slower. The SQL Engine might be smart enough to figure out what you have done and fix things under the covers but it might not.
================================================= We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry