J.P. Morgan Interview Question

2 SQL query