select * from T1 where Location in
(select top 1 * from (
select location,count(*) as reccount
from T1 group by location) x order by reccount desc)

解决方案 »

  1.   

    select name location from Table1
    where location = (select top 1 location from table1
    group by count(location) 
    order by count(*) desc 
    )
      

  2.   

    1.如果人数最多的location多于一个,能处理
    select *
    from T1
    where Location in (select Location 
                      from T1 
                  group by Location
                    having count(*) = (select max(f) 
                                       from (select count(*) f 
                                               from T1 
                                           group by Location) T))
    2.(如果人数最多的location多于一个不能处理,加with ties即可)
    select *
    from T1
    where Location in (select Top 1  with ties Location 
                      from T1 
                  group by Location 
                  order by count(*) desc)