XYZ interview question

Sql queries