Nested Aggregate Functions Postgresql Interview