8,497
社区成员
发帖
与我相关
我的任务
分享
select top 5 authorName,count(*)
from dbo.authors
group by authorName
having authorName like '赵%'
order by count(*) desc
V1DataContext DB = new V1DataContext();
var queryName = (from A in DB.authors
group A by new
{
authorName = A.authorName
} into grA
select new
{
authorName = grA.Key.authorName,
Quantity = grA.Count()
} into orderbygrA
where orderbygrA.authorName.StartsWith("张")
orderby orderbygrA.Quantity descending
select orderbygrA.authorName).Distinct().Take(7);
var query=(from A in DB.authors.Where(b=>b.authorName.StartsWith("张"))
group A by A.authorName into g
let c=g.Count()
orderby c desending
select new {authorName=g.Key,cnt=c}).Take(5);
V1DataContext DB = new V1DataContext();
var queryName = (from A in DB.authors
group A by new
{
authorName = A.authorName
} into grA
select new
{
authorName = grA.Key.authorName,
Quantity = grA.Count()
} into orderbygrA
where orderbygrA.authorName.StartsWith("赵")
orderby orderbygrA.Quantity descending
select orderbygrA.authorName).Distinct().Take(5);
V1DataContext DB = new V1DataContext();
var queryName = (from A in DB.authors
group A by new
{
authorName = A.authorName
} into grA
select new
{
authorName = grA.Key.authorName,
Quantity = grA.Count()
} into orderbygrA
where orderbygrA.authorName.StartsWith("张")
orderby orderbygrA.Quantity descending
select orderbygrA.authorName).Distinct().Take(5);