eClerx interview question

How to optimize a query