EY interview question

Mainly about database queries using joins and aggregate functions.