ION Group interview question

DBMS, SQL queries and some puzzles