Need to write a SQL query to fetch data from a Oracle database
I need to write a SQL query which can fetch a data from one table A.
Senario - Lets take table A has only two column C1 and C2. C1 has row_id's and C2 has vaues like "Site=google;site=gmail,site=yahoo"
Requirment开发者_JS百科 - Need to write a query which can fetch all the row_id from column C1 of table A but the value should come for column C2 as "google;gmail;yahoo". Means it should not show "Site=" for all the values of C2 column in the data fetch. And one more condition that if there is , in place of ; in the value then query should convert it into ; and show the data.
How about this:
SELECT C1, REPLACE(REPLACE(C2, 'Site=', ''), ',', ';') AS C2
FROM TABLE
Share and enjoy.
精彩评论