Amazon Interview Question

For the SQL question, it was pretty basic calculation.