这是我的问题。我有一个这样的选择语句:
select * from mytable where mycol like '%finance%'
结果如下所示:
id mycol
16 the finance department
8 i like the finance people
43 chief finance officer
22 finance
68 finance trading
我想让订单像这样出来:
id mycol
22 finance
68 finance trading
43 chief finance officer
16 the finance department
8 i like the finance people
本质上,要让选择查询使用:
where mycol = 'finance'
然后
where mycol = 'finance%'
然后
where mycol = '%finance%'
1) 我不能将 id 列用于订购目的。
2)我的查询比这复杂得多(它是使用 SELECT TOP 1000000 ROW_NUMBER() OVER (ORDER BY t.category, t.sequence) 在大型数据库上分页记录集的一部分...
我想我可能需要使用 UNION 或 RANK() 或其他东西,但我现在已经脱离了我的联盟。非常感谢任何指导:)