sum(decode(instr( x_field , 'A'),0,0,1)) a_sum,sum(decode(instr( x_field , 'B'),0,0,1)) b_sum,sum(decode(instr( x_field , 'C'),0,0,1)) c_sum,from x_tab
select length(PERIODS)-length(replace(PERIODS,','))+1 from test
oracle ',,,|,,,'分别取出第一个逗号之间的字符 ect substr(字符串,instr(字符串,',',1)+1,instr(字符串,',',instr(字符串,',',1)+1)-instr(字符串,',',1)-1) from dual
select * from tablename where regexp_like('abc,ad,a', ',[\s]*ad[\s]*,') --第一个参数是你的列
select id ,listagg( name, ',' ) within group ( order by id ) as name from TABLE_NAME GROUP BY id;
select a.*, c.value('.','varchar(50)') as list from 表 across apply(select cast('<row>'+replace(sxsx,',','</row><row>')+'</row>' as xml) as xmlcode) C1cross apply xmlcode.nodes('*') t(c)where c.value('.','varchar(50)') like '三星'...
SELECT rownum, t.aid, wm_concat (t1.name) FROM leader t INNER JOIN leader_name t1 ON INSTR( CONCAT(',', t.aid, ','), CONCAT(',', t1.bid, ',') ) > 0 GROUP BY t1.aid ;试试,思路就是根据字符串截取,匹配id,然后group by,行转列。防止那种1...
方法1:SELECT CASE WHEN 性别列的列名=0 THEN '男'WHEN 性别列的列名=1 THEN '女'END as sex,age_colname as age FROM 你要查找的表名 WHERE 条件子句 方法2:使用内置函数转换。(呵呵,没分,够用就行了。)=>补充:1 你的错误i guess 因为几个栏位之间没有用逗号分隔造成的。2 内置...
substr(字符串,开始位置,截取位数)用上面的函数可以完成你要的判断 如果是查询 select case substr(字段,1,1)when ',' then substr(字段,2,length(字段) - 1)else 字段 end as 字段名 from 表
(select COLUMN_NAME,column_id from user_tab_columns where table_name='&表名')start with column_id=1 connect by column_id=rownum;从这点上讲Oracle比SQLSERVER取字段要麻烦多了 在SQLSERVER里可以直接在SQL的查询分析器中直接选中表右击选select就可以自动生成表的所有字段名用逗号分割 ...