select x.a,min(y.b) b from x inner join y on x.a=y.a group by x.aselect y.a,min(y.b) b from y group by y.a