
正文
oracle如何统计人数 oracle 统计数量
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
oracle,如何统计各个姓氏的人数,且以升序排序?
select substr(姓名,1,1) as 姓氏,coun(1) as 人数 from 表 group by substr(姓名,1,1)
order by 人数
相关问答
Q1: oracle中统计每个部门下的人数怎么写
SELECT D.DEPTNO, D.DNAME, COUNT(E.EMPNO) FROM SCOTT.EMP E, SCOTT.DEPT D WHERE E.DEPTNO = D.DEPTNO GROUP BY cube(D.DEPTNO, D.DNAME)
Q2: oracle sql怎样统计数量
可以通过district来取出字段,之后通过count计算总数量。
sql:select count(district id) from tablename;
如果id字段没有空值的话,可以通过count统计字段的总数量(字段内容可能重复)。
sql:select count(id) from tablename;
Q3: oracle 年龄段统计
年龄段统计可用case when 语句。
如test表中有以下数据:
其中18-29岁为青年,30-49岁为中年,50岁以上为老年,先统计各个年龄段人数,可用如下语句:
select case when age between 18 and 29 then '青年' when age between 30 and 59 then '中年' when age=60 then '老年' end as 年龄段,
count(*) as 人数
from test
group by case when age between 18 and 29 then '青年' when age between 30 and 59 then '中年' when age=60 then '老年' end;
统计结果:






