求一个统计的SQL语句 表的结构是这样的 mem_id(卡号),act_loc(活动地点),act_dte(活动日期)现在要对活动次数做统计,对活动次数分组。要求显示 次数 人数1 1002 603 5010 2 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(*) 次数,count(卡号) 人数from tbgroup by 活动地点 修改:select count(distinct 活动地点) 次数,count(卡号) 人数 from tb group by 活动地点 select cs,count(*) from (select mem_id,count(*) as cs group by mem_id) group by cs;意思是先统计出每人参加的次数,再根据次数统计人数,是这样吧? 不好意思,语法错误,正确的是:select cs,count(*) from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs; 不好意思,语法错误,正确的是:select cs,count(*) as rs from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs; Allan_xd正确,你的语句里少了from 表名 sqlplus sys/xx@orcl 报错ora-12518,求指点 相同数据,不同机器配置,存储过程运行结果不一样 数据导入问题 IMP 中参数SHOW 的使用 字段设计时候,用125/256,要比100这样的整数好吗? oracle审计相关表 用C向oracle里添加数据 编译java source 出错! oracle的SQL语句出错.谁帮我看看 服务 OracleOraHome90PagingServer 已经存在的问题 急急急!!!后台切换应注意的问题???? 求助CNOUG论谈的邀请码,谢谢! ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
from tb
group by 活动地点
select count(distinct 活动地点) 次数,count(卡号) 人数
from tb
group by 活动地点
意思是先统计出每人参加的次数,再根据次数统计人数,是这样吧?
select cs,count(*) from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs;
select cs,count(*) as rs from (select mem_id,count(*) as cs from yourtable group by mem_id) group by cs;