Postgres Count Distinct In Pivot Table