本帖最后由 jauia 于 2011-08-04 20:00:52 编辑

解决方案 »

  1.   


    declare @a table(id int,city_id int,title varchar(10))
    insert into @a
    select 1,1,'xx'   union all
    select 2,2,'xxx'  union all
    select 3,3,'xxxx' union all
    select 4,1,'xxx'  union all
    select 5,2,'xxxx' union all
    select 6,2,'xxxx'  select * from @a
    select distinct city_id,count(title) as [count(title)]  from @a group by city_id;