Postgres Loop Through Array Backwards C