Amazon Interview Question

Different ways of optimizing a query