DbContext dd = new SZAdminEntities();
list = dd.Set<BUS_VisitorStatics>().OrderByDescending(p => p.Count).ToList();
dateList = g.OrderByDescending(p => p.Count).Take(10),
var wordlist = new List<BUS_VisitorStatics>();
foreach (var item in result)
{
if (item.dateList.Count() > 0)
{
foreach (var o in item.dateList)
{
var mod = new BUS_VisitorStatics();
mod.VisitorDate = item.date;
mod.Count = o.Count;
mod.Keyword = o.Keyword;
wordlist.Add(mod);
}
}
}
return wordlist;
3、普通SQL实现:
SELECT *
FROM BUS_VisitorStatics AS a
WHERE ( SELECT COUNT(*)
FROM BUS_VisitorStatics AS b
WHERE a.VisitorDate = b.VisitorDate
AND a.Count < b.Count
) < 10
ORDER BY a.VisitorDate ,a.Count DESC