Will something like this work?
namelist = ExecuteSQL ( "SELECT Name, COUNT(*) AS items FROM Child WHERE fk_ParentID = ? GROUP BY Name ORDER BY items DESC"; "" ; "" ; ID );
firstinlist =GetValue( Substitute( namelist; ","; "¶"); 1) ];
note: items is a calculated SQL field so you can use it without the calc in filemaker. This grabs the first item in a reverse sorted list based on frequency of Name which may not work as desired when the most frequent results in a tie.
This will work in version 12, did not give your OS or Version of Filemaker.
Message was edited by: timwhisenant
Thanks very much for that. I shall have a go later and see how I get on. Sorry it is v12 on a Mac.