Tecnotree Interview Question

SQL query