Infosys interview question

Dsa and sql and one puzzle