PMG Digital Company Interview Question

How would you do this task in SQL/how would you work it out.