podrías hacer
select s.x, s.mz, stuff.y
from (select x, max(z) as mz from stuff group by x) s
left join stuff on stuff.x = s.x and stuff.z = s.mz;
podrías hacer
select s.x, s.mz, stuff.y
from (select x, max(z) as mz from stuff group by x) s
left join stuff on stuff.x = s.x and stuff.z = s.mz;