Quantiphi interview question

SQL queries, Puzzles, DBMS