Greensky interview question

SQL queries based on aggregation and Case statements