需要编写一个SQL查询以从Oracle数据库中获取数据 [英] Need to write a SQL query to fetch data from a Oracle database
问题描述
我需要编写一个SQL查询,该查询可以从一个表A中获取数据.
I need to write a SQL query which can fetch a data from one table A.
Senario-让表A仅具有两列C1和C2. C1具有row_id,C2具有诸如"Site = google; site = gmail,site = yahoo"之类的值
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"
需求-需要编写一个查询,该查询可以从表A的列C1中获取所有row_id,但列C2的值应为"google; gmail; yahoo".意味着对于数据提取中C2列的所有值,它都不应显示"Site =.还有一个条件,如果存在,代替;在值中,然后查询应该将其转换为;并显示数据.
Requirment - 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.
推荐答案
这是怎么回事:
SELECT C1, REPLACE(REPLACE(C2, 'Site=', ''), ',', ';') AS C2
FROM TABLE
分享并享受.
这篇关于需要编写一个SQL查询以从Oracle数据库中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!