Pgsql Distinct Sql Function To Get Current