Pregunta de entrevista de Amazon

For the SQL question, it was pretty basic calculation.