SELECT RequirementId,Title,ProjectId,Keywords, 0 as keywordcount
INTO #t1
FROM
(
select *
from dbo.Requirement
where Keywords is not null and Keywords <> ''  and ProjectId=11
and (Keywords like '%关键字1%' or  Keywords like '%关键字2%' or Keywords like '%关键字3%')
) AS TEMPTABLE
select * from #t1 order by keywordcount desc, RequirementID desc
update #t1
set keywordcount = keywordcount +1
where Keywords like '%关键字1%'
update #t1
set keywordcount = keywordcount +1
where Keywords like '%关键字2%'
update #t1
set keywordcount = keywordcount +1
where Keywords like '%关键字3%'
select * from #t1 order by keywordcount desc, RequirementID desc
drop table #t1
posted on 2011-11-11 10:07  凌度  阅读(258)  评论(0编辑  收藏  举报