分拆统计字符串
来源:互联网 发布:工资管理系统数据库 编辑:程序博客网 时间:2024/05/16 10:28
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在表tbl1中有一个字段Keywords,它是nvarchar类型,长度为1000,该字段的内容是所要分析的论文的关键字id keywords-----------------------------------------------------------1 kw1;kw2;kw32 kw2;kw33 kw3;kw1;kw4
问题1。对于在keywords字段中出现的所有关键字集合(上例中关键字集合为{kw1,kw2,kw3,kw4})中的任意一个关键字,要统计它出现的次数(也就是包含该关键字的纪录的条数),然后写到另一张表中。最后的效果就是keywords count-------------------------kw1 2kw2 2kw3 3kw4 1
问题2。在此基础上,要进行组合查询。也就是说在整个关键字集合中任意抽出两个关键字,统计它们在数据库表纪录中同时出现的次数。对于上题,最后效果要是:keywords count----------------------------------kw1;kw2 1kw1;kw3 2kw1;kw4 1kw2;kw3 2kw2;kw4 0kw3;kw4 1
--------------------------------------------------------------------------------------
--统计示例
--为统计处理专门做的序数表selecttop1000id=identity(int,1,1)into序数表fromsyscolumnsa,syscolumnsbaltertable序数表addconstraintpk_id_序数表primarykey(id)go
--示例数据createtabletbl1(idint,keywordsnvarchar(1000))inserttbl1select1,'kw1;kw2;kw3'union all select2,'kw2;kw3'union all select3,'kw3;kw1;kw4'go
--第一种统计(计数)selectkeyword=substring(a.keywords,b.id,charindex(';',a.keywords+';',b.id)-b.id) ,[count]=count(distincta.id)fromtbl1a,序数表bwhereb.id<=len(a.keywords) andsubstring(';'+a.keywords,b.id,1)=';'groupbysubstring(a.keywords,b.id,charindex(';',a.keywords+';',b.id)-b.id)go1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在表tbl1中有一个字段Keywords,它是nvarchar类型,长度为1000,该字段的内容是所要分析的论文的关键字id keywords-----------------------------------------------------------1 kw1;kw2;kw32 kw2;kw33 kw3;kw1;kw4
问题1。对于在keywords字段中出现的所有关键字集合(上例中关键字集合为{kw1,kw2,kw3,kw4})中的任意一个关键字,要统计它出现的次数(也就是包含该关键字的纪录的条数),然后写到另一张表中。最后的效果就是keywords count-------------------------kw1 2kw2 2kw3 3kw4 1
问题2。在此基础上,要进行组合查询。也就是说在整个关键字集合中任意抽出两个关键字,统计它们在数据库表纪录中同时出现的次数。对于上题,最后效果要是:keywords count----------------------------------kw1;kw2 1kw1;kw3 2kw1;kw4 1kw2;kw3 2kw2;kw4 0kw3;kw4 1
--------------------------------------------------------------------------------------
--统计示例
--为统计处理专门做的序数表selecttop1000id=identity(int,1,1)into序数表fromsyscolumnsa,syscolumnsbaltertable序数表addconstraintpk_id_序数表primarykey(id)go
--示例数据createtabletbl1(idint,keywordsnvarchar(1000))inserttbl1select1,'kw1;kw2;kw3'union all select2,'kw2;kw3'union all select3,'kw3;kw1;kw4'go
--第一种统计(计数)selectkeyword=substring(a.keywords,b.id,charindex(';',a.keywords+';',b.id)-b.id) ,[count]=count(distincta.id)fromtbl1a,序数表bwhereb.id<=len(a.keywords) andsubstring(';'+a.keywords,b.id,1)=';'groupbysubstring(a.keywords,b.id,charindex(';',a.keywords+';',b.id)-b.id)go1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 分拆统计字符串
- 字符串分拆查询
- 字符串分拆函数
- 短信字符串分拆
- 短信字符串分拆
- 字符串分拆函数
- 短信字符串分拆
- SQL模拟达芬奇密码中文站首页数字游戏
- 美国职业生涯规划与时间管理专家Brian Tracy
- 防盗器主机的原理与修理
- 随机选择表格里的行
- Unix文件系统研究: 4. 文件类型 用户权限
- 分拆统计字符串
- MINFO-印度铁矿资源矿物信息原型
- 更新字符串列表中,指定位置的字符串
- C# "未将对象引用设置到对象的实例"异常的原因 总结
- 得到指定字符串列表中,指定个数的字符串
- 创建作业的通用存储过程
- OK,let's go!
- SQLBUG集之"随机排序中的newid()问题"
- 不可小视视图对效率的影响力