How to return result of a SELECT inside a function in PostgreSQL? How to return result of a SELECT inside a function in PostgreSQL? sql sql