How to remove a trailing comma at the end of a string in Oracle

So I'm working in a database and in a particular column there is a trailing comma that I need to remove, a simple solution is something like this: We have something like this

SELECT 'a, b, c, d,' test From  dual;
The output is:

a, b, c, d,
To clean the last comma we can use RTRIM

SELECT RTRIM('a, b, c, d,', ',') new_test From  dual;
The output is:

a, b, c, d
Pretty neat!!!! RTRIM function Source 2

No comments: