Postgresql Count Distinct Case When