Hello,
Your version seems to me that unless a solution using SQL will be good. Check out this guide and adjust to their data
https://www.youtube.com/watch?v=EAf6Lhmjh-c