Sql While Loop Through Array Backwards