Postgresql Aggregate Functions Cannot Be Nested If Function In Excel