Postgres Row Number Partition By Teradata