'How to use CAST/CONVERT in redshift to Convert VARCHAR to INTEGER?

I am loading data from s3 (.csv files), where i have a column Agent_answer_rate with some float values along with "%" sign e.g. 84.00%, 90.00%. i have declared VARCHAR as datatype for this column and its working fine and loading data from s3 and inserting it into my redshift table. But the requirement is to define INTEGER datatype for this column when i changed the datatype it throws an error of delimiter. Is there any way as i can set INTEGER/NUMERIC datatype for such data having "%" with value.
Here is the error when i set INTEGER datatype
This is the Redshift column with VARCHAR datatype

I just want to store values with "%" sign in INTEGER datatype.
I have tried to change the datatype:

select cast(Agent_answer_rate as integer) from
(select
 case when Agent_answer_rate ~ '^[0-9]+%' then Agent_answer_rate     
 end as Agent_answer_rate     
 from boxie24_Test);

But after changing the datatype it converts all values to null values as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source