oracle SQL 查询某一字段中的字符串出现的次数
如表T:T1T21A,B,C2A,B3B,C查询出的结果如下P:P1P2A2B3C2其实就是查A,B,C在表T1中出现的次数。T表中T2的“A,B,C”可以有C,D,.....
如表T :
T1 T2
1 A,B,C
2 A,B
3 B,C
查询出的结果如下P:
P1 P2
A 2
B 3
C 2
其实就是查A,B,C在表T1中出现的次数。T表中T2的“A,B,C”可以有C,D,......
系统已经上线,客户要新增一报表,希望有人能帮下,在此谢谢!!! 展开
T1 T2
1 A,B,C
2 A,B
3 B,C
查询出的结果如下P:
P1 P2
A 2
B 3
C 2
其实就是查A,B,C在表T1中出现的次数。T表中T2的“A,B,C”可以有C,D,......
系统已经上线,客户要新增一报表,希望有人能帮下,在此谢谢!!! 展开
展开全部
select 'A' P1,a.P2
from (select count(1) P2 from t where t.t2 like '%A%' ) a
union all
select 'B',b.P2
from (select count(1) P2 from t where t.t2 like '%A%' ) b
.....
from (select count(1) P2 from t where t.t2 like '%A%' ) a
union all
select 'B',b.P2
from (select count(1) P2 from t where t.t2 like '%A%' ) b
.....
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select id=identity(int,1,1)
into #a from dbo.syscolumns a, dbo.syscolumns b
select substring(a.t2,b.id,charindex(',',a.t2+',',b.id)-b.id),count(a.t1)
from tablet a,#a b
where b.id<=len(a.t2)
and substring(','+a.t2,b.id,1)=','
group by substring(a.t2,b.id,charindex(',',a.t2+',',b.id)-b.id)
into #a from dbo.syscolumns a, dbo.syscolumns b
select substring(a.t2,b.id,charindex(',',a.t2+',',b.id)-b.id),count(a.t1)
from tablet a,#a b
where b.id<=len(a.t2)
and substring(','+a.t2,b.id,1)=','
group by substring(a.t2,b.id,charindex(',',a.t2+',',b.id)-b.id)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select B.A,count(*) total from A,B where A.A like '%'+B.A+'%' group by B.A
下面是赠送的:
select chr(ascii('A') + level - 1) from dual connect by rownum <= 26
如果看不懂或你还搞不定就留下言
下面是赠送的:
select chr(ascii('A') + level - 1) from dual connect by rownum <= 26
如果看不懂或你还搞不定就留下言
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select 'A',a.P2
from (select count(1) P2 from t where t.t2 like '%A%' ) a
union
select 'B',b.P2
from (select count(1) P2 from t where t.t2 like '%B%' ) b
union
..........
最好调用存储过程
from (select count(1) P2 from t where t.t2 like '%A%' ) a
union
select 'B',b.P2
from (select count(1) P2 from t where t.t2 like '%B%' ) b
union
..........
最好调用存储过程
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询