Postgresql Count Distinct In Pivot