我有这个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”时,它会根据该名称找到最可能的类别匹配。
任何帮助将不胜感激:)