Amdocs Interview Question

Some sql queries and a puzzle was there.