Ascend Group Interview Question

SQL Query, Database Tool, Logic