Amdocs interview question

Sql query