Postgresql Loop Through Array Backwards Hat