[英]Need to remove spaces in between days and add comma using sql
I would like to remove spaces and add commas in between the data using SQL.我想使用 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:在 Oracle 中,您可以使用:
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 REPLACED_VALUE mon,tue,wed,thu周一、周二、周三、周四
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.