日期:2014-05-18 浏览次数:20620 次
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([id] int,[text] varchar(38))
insert [tb]
select 1,'我是中国人' union all
select 2,'大家好,我是中人中人是' union all
select 3,'你们好吗?我是我是' union all
select 4,'大家来帮个忙,我不是中国的.我是外国的是'
go
select * from tb
order by
len([text])-len(replace([text],'是','')) desc,
len([text])-len(replace([text],'人','')) desc
/**
id text
----------- --------------------------------------
4 大家来帮个忙,我不是中国的.我是外国的是
2 大家好,我是中人中人是
3 你们好吗?我是我是
1 我是中国人
(4 行受影响)
**/