博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
根据匹配词个数排序
阅读量:7240 次
发布时间:2019-06-29

本文共 877 字,大约阅读时间需要 2 分钟。

法一:

select title,(case when CHARINDEX('Log4net',title)>0 then 1 else 0 end )+(case when CHARINDEX('oracle',title)>0 then 1 else 0 end ) counts from T_KNOWLEDGE where title like '%Log4net%' or title like '%oracle%' order by counts desc

法二:

select title from T_KNOWLEDGE where title like '%Log4net%' or title like '%oracle%' order by (case when CHARINDEX('Log4net',title)>0 then 1 else 0 end )+(case when CHARINDEX('oracle',title)>0 then 1 else 0 end ) desc

 

带分页的:

with cte as(

select *,row_number() over(order by CREATED_TIME desc) rn from (select title,(case when CHARINDEX('Log4net',title)>0 then 1 else 0 end )+(case when CHARINDEX('oracle',title)>0 then 1 else 0 end ) counts from T_KNOWLEDGE where title like '%Log4net%' or title like '%oracle%' order by counts desc
) t
)select * from cte where rn between 1 and 10;

 

转载于:https://www.cnblogs.com/ChineseMoonGod/p/4989178.html

你可能感兴趣的文章
C#委托的介绍(delegate、Action、Func、predicate)
查看>>
巧用Scrum与Kanban
查看>>
质量报告之我见
查看>>
微信域名weixin.com天价成交!是腾讯吗?
查看>>
C#实现远程机器管理
查看>>
Android生成带图片的二维码
查看>>
jQuery对表单、表格的操作及更多应用(下:其他应用)
查看>>
[.net 面向对象编程基础] (21) 委托
查看>>
阶乘相关问题
查看>>
ASP.NET MVC导出excel(数据量大,非常耗时的,异步导出)
查看>>
Java引用类型变量
查看>>
利用window.navigator.userAgent判断当前是否微信内置浏览器
查看>>
《Programming WPF》翻译 第9章 2.选择一个基类
查看>>
IOS-整体框架类图
查看>>
在Ubuntu下安装*.sh
查看>>
NavigationBar 隐藏底部边线,阴影
查看>>
三种最典型的大数据存储技术路线
查看>>
stl非变易算法(二)
查看>>
java 关键字 transient
查看>>
Ubuntu配置和修改IP地址
查看>>