sql 找到前三

drop table #cont

 

select a,b,count(a) as cut

into #cont

from test

group by a,b

order by a,bcount(a) desc

 

select * from #cont cont1 where  cont1.b in(select top 3 b from #cont cont2 where cont2.a=cont1.a )

posted @ 2015-07-24 16:04  小小zkj  阅读(290)  评论(0编辑  收藏  举报