Prishusoft interview question

SQL query