Skip to content
Advertisement

Trim Intermediate spaces in a string in Postgres

In the result, want only intermediate spaces to be removed.

Need to print only first part before hypen (-) along with Percentages.

Can you please help.

Input String: AMAZON – 25%; SAP – XXXXX – 45%; MICROSOFT – XXX&YYY – 30%

Query:

Advertisement

Answer

regexp_split_to_table can be used to split the value into strings by the delimiter ;, then you can use split_part to get the first and second parts of the desired result.

Data Output:

first second
SUCCESS FACTORS 25%
SAP 45%
MICROSOFT 30%
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement