Ok, as easiest as i can explain.
child.id is just the id of a child row. And each row has rating column.
$construct = "SELECT child.* FROM outcomes child JOIN outcomes parent on parent.id=child.sid JOIN WHERE (parent.name LIKE '%$search%') GROUP BY child.nid,child.sid ORDER BY child.rating DESC";
I've tried ORDER BY child.rating DESC but this needs to happen before the GROUP BY child.nid.
Any idea how to solve this problem?