我有这个 SQL,但我需要将它转换为 Linq 查询。尝试同时使用 partition/rownum 和 patition/count 时遇到困难。
Select TOP 1 vals.c3, (vals.Rank * vals.[Occurances]) as RNK
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY c1 asc) as Rank, Count(*) Over(Partition By c3) As [Occurances], c3
FROM dbo.ranks
WHERE c2 in ('ADAMS', 'CHIP', 'SHOP')
group by c3,c2,c1
) vals
--group by vals.c3
ORDER BY RNK desc
这是排名列表的样子:
c1 c2 c3
26774 CHIP Chipshop
26054 SHOP Shops
10054 SHOP Chipshop
23037 MEDICAL Doctors
21434 CENTRE Doctors
12803 DENTAL Dentists
11847 OFFICE Post Offices
c2 是单词,c3 是我要查找的类别。c1 是该词在每个类别中出现的频率。因此,当我输入搜索“Adams Chip shop”时,它会根据该名称查找最可能匹配的类别。
任何帮助,将不胜感激 :)