Det kan du göra
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;
Det kan du göra
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;