J.P. Morgan interview question

Questions were on building SQL queries