Postgres If Function For Multiple Conditions