Postgresql Loop Through Array Backwards K