Lyft interview question

SQL - Calculations based on two tables, similar to LC medium