I would like to remove spaces and add commas in between the data using SQL. Like if I have column with the data ' mon tue wed thu '
I need it to be like 'mon,tue,wed,thu'
Can someone help me with this.
I would like to remove spaces and add commas in between the data using SQL. Like if I have column with the data ' mon tue wed thu '
I need it to be like 'mon,tue,wed,thu'
Can someone help me with this.
In Oracle, you can use:
SELECT TRIM(BOTH ',' FROM REGEXP_REPLACE(value, '\s+', ',')) AS replaced_value
FROM table_name;
Which, for the sample data:
CREATE TABLE table_name (value) AS
SELECT ' mon tue wed thu ' FROM DUAL
Outputs:
REPLACED_VALUE mon,tue,wed,thu
db<>fiddle here