--查询处理--创建处理用到的临时表
select top 8000 id=identity(int,1,1) into #t
from syscolumns a,sysobjects bselect 字母=substring(Letter,b.id,1),个数=count(*)
from 表 a join #t b on b.id<=len(a.Letter)
group by substring(Letter,b.id,1)
order by 个数 desc--删除处理用的临时表
drop table #t
select top 8000 id=identity(int,1,1) into #t
from syscolumns a,sysobjects bselect 字母=substring(Letter,b.id,1),个数=count(*)
from 表 a join #t b on b.id<=len(a.Letter)
group by substring(Letter,b.id,1)
order by 个数 desc--删除处理用的临时表
drop table #t
create table 表(ID int,Letter varchar(100))
insert 表 select 1,'acmtdk'
union all select 2,'abdset'
union all select 3,'efsdwq'
go--查询处理--创建处理用到的临时表
select top 8000 id=identity(int,1,1) into #t
from syscolumns a,sysobjects bselect 字母=substring(Letter,b.id,1),个数=count(*)
from 表 a join #t b on b.id<=len(a.Letter)
group by substring(Letter,b.id,1)
order by 个数 desc--删除处理用的临时表
drop table #t
go--删除测试
drop table 表/*--测试结果字母 个数
---- -----------
d 3
e 2
t 2
s 2
a 2
c 1
b 1
f 1
q 1
m 1
k 1
w 1(所影响的行数为 12 行)
--*/
select top 8000 id=identity(int,0,1) into #t
from syscolumns a,sysobjects bselect 字母,个数=count(*)
from(
select 字母=substring(Letter,b.id*2+1,2)
from 表 a join #t b on b.id<len(a.Letter)/2
)a group by 字母
order by 个数 desc--删除处理用的临时表
drop table #t
create table 表(ID int,Letter varchar(100))
insert 表 select 1,'acmtdk'
union all select 2,'abdset'
union all select 3,'efsdwq'
go--查询处理--创建处理用到的临时表
select top 8000 id=identity(int,0,1) into #t
from syscolumns a,sysobjects bselect 字母,个数=count(*)
from(
select 字母=substring(Letter,b.id*2+1,2)
from 表 a join #t b on b.id<len(a.Letter)/2
)a group by 字母
order by 个数 desc--删除处理用的临时表
drop table #t
go--删除测试
drop table 表/*--测试结果
字母 个数
---- -----------
sd 1
dk 1
ds 1
ac 1
ab 1
mt 1
ef 1
et 1
wq 1(所影响的行数为 9 行)
--*/