Here is one option:
select child, (select count(*) from meals m where m.child = l.child and m.fruit = ?) cnt from listing l where ? in (local_fruit_1, local_fruit_2, local_fruit_3) order by cnt
The logic is to filter the
listing table for rows where the concerned fruit can be found. Then, we use a correlated subquery to bring the count of fruits that were eaten.
The question marks represent the fruit whose analysis you want to bring.
CLICK HERE to find out more related problems solutions.