62,046
社区成员
发帖
与我相关
我的任务
分享
select id,COUNT(id) from @table group by id ORDER BY COUNT(id) DESC
create table #table (id int)
insert into #table
select 12 union all
select 11 union all
select 11 union all
select 12 union all
select 12 union all
select 12
select id,count(1) as c from #table group by id order by c desc
/*
12 4
11 2
*/
va order=db.AsEnumerable().Group(t=>t.Field<int>("id")).OrderByDescend(g=>g.Count());
select id from tb_news where charindex('车',keyword)>0 union all select id from tb_news where charindex('汽车',keyword)>0
declare @table table(id int)
insert into @table
select 12 union all
select 11 union all
select 11 union all
select 12 union all
select 12 union all
select 12
select list.* from @table list
LEFT JOIN
(
select id,COUNT(1) cou from @table group by id
) T ON T.id = list.id
order by T.cou DESC
/*
(6 行受影响)
id
-----------
12
12
12
12
11
11
(6 行受影响)
*/