The way approach things like this is to break it down into steps, usually from the "inside out". First, you want to find the set of ref_no where it is a maximum for each name:
SELECT MAX(ref_no) FROM yourtable GROUP BY name;
Them you want the rows in your table where the ref_no is in this set:
SELECT ref_no, name FROM yourtable
WHERE ref_no IN (SELECT MAX(ref_no) FROM yourtable GROUP BY name);
This resultset will be in an arbitrary order, so you may want to order it:
SELECT ref_no, name FROM yourtable
WHERE ref_no IN (SELECT MAX(ref_no) FROM yourtable GROUP BY name)
ORDER BY ref_no;
Jeff Mason
[email protected]