表的结构是这样的 mem_id(卡号),act_loc(活动地点),act_dte(活动日期)现在要对活动次数做统计,对活动次数分组。要求显示 
次数  人数
1     100
2     60
3     50
10    2 

解决方案 »

  1.   

    select count(*) 次数,count(卡号) 人数
    from tb
    group by 活动地点
      

  2.   

    修改:
    select count(distinct 活动地点) 次数,count(卡号) 人数 
    from tb 
    group by 活动地点
      

  3.   

    select cs,count(*) from (select mem_id,count(*) as cs group by mem_id) group by cs;
    意思是先统计出每人参加的次数,再根据次数统计人数,是这样吧?
      

  4.   

    不好意思,语法错误,正确的是:
    select cs,count(*) from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs;
      

  5.   

    不好意思,语法错误,正确的是:
    select cs,count(*) as rs from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs;
      

  6.   

    Allan_xd正确,你的语句里少了from 表名