Amazon interview question

Different ways of optimizing a query