select a.userid,a.username,max(c.address)from A a,B b,C c where a.userid=b.userid and b.addid=c.addidgroup by a.userid,a.username