新疆4.23暴力恐怖事件,微信登陆网页版,各省最富最穷
if object_id('tb')is not null drop table tb
go
create table tb (id int identity(1,1),value nvarchar(100))
insert tb select n'中国'
union all select n'中国人'
union all select n'中国人民'
union all select n'日本'
union all select n'日本人'
union all select n'我的心中有人姑娘'
union all select n'人民网'
union all select n'中国是个伟大的国家'
union all select n'我们都是中国人,都是炎黄子孙,都是龙人传人'
if object_id('fn_splitstringtorows')is not null drop function fn_splitstringtorows
go
create function fn_splitstringtorows
(
@str nvarchar(100)
)
returns @t table(v nvarchar(2))
as
begin
declare @i int
set @i=1
while @i<=len(@str)
begin
insert @t select substring(@str,@i,1)
set @i=@i+1
end
return
end
go
select * from dbo.fn_splitstringtorows(n'中国人')
declare @searchstr nvarchar(20)
set @searchstr=n'中国人'
select id,[value] from tb a
inner join fn_splitstringtorows(@searchstr) b
on charindex(b.v,a.value)>0
where value like n'%[中国人]%'
group by id,value
order by count(distinct v) desc
drop table tb
/*
v
----
中
国
人
(3 個資料列受到影響)
id value
----------- ----------------------------------------------------------------------------------------------------
2 中国人
3 中国人民
9 我们都是中国人,都是炎黄子孙,都是龙人传人
6 我的心中有人姑娘
1 中国
8 中国是个伟大的国家
5 日本人
7 人民网
(8 個資料列受到影響)
*/
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
sql某个日期是当年的第几周
/* *周一作为一周的开始 *当年的1月1号所在的周算作第一周 */ CREATE function GetWeekIndexFirstDate ( @...
[阅读全文]
-
-
数据库SQL---范式
1、数据冗余导致的问题:冗余存储、更新异常、插入异常、删除异常。 2、函数依赖:一种完整性约束。 在关系模式r(R)中,α属于R,β属于R。 1)α函数...
[阅读全文]
-
-
数据库SQL---查询
1、查询所有列 select *from emp;--*表示所有的,from emp表示从emp表中查询。 2、查询指定列 select empno,e...
[阅读全文]
-
-
-
-
-
网友评论