Cognizant Interview Question

Using a subquery for a tough application.