Postgres View Function Sql Syntax Order