Oracle中sql语句分组后怎样统计出有多少分组
答案:3 悬赏:30 手机版
解决时间 2021-02-22 20:25
- 提问者网友:骑士
- 2021-02-22 14:31
在我的表中我按人员id分组,目的是想用此sql语句返回统计分组数,请问我该怎么写?(就是我分了多少组)
最佳答案
- 五星知识达人网友:行路难
- 2021-02-22 15:38
再套一层:
select COUNT(1)
from (select a.col1
from (select '11' col1 from dual
union all
select '22' from dual
union all
select '33' from dual
union all
select '11' from dual
union all
select '33' from dual
union all
select '22' from dual
union all
select '33' from dual
union all
select '11' from dual) a
group by a.col1) t
select COUNT(1)
from (select a.col1
from (select '11' col1 from dual
union all
select '22' from dual
union all
select '33' from dual
union all
select '11' from dual
union all
select '33' from dual
union all
select '22' from dual
union all
select '33' from dual
union all
select '11' from dual) a
group by a.col1) t
全部回答
- 1楼网友:琴狂剑也妄
- 2021-02-22 18:33
select department,
sum(case when 员工种类=1 then 工资 else 0 end) 员工种类为1的工资总额,
sum(case when 员工种类=2 then 工资 else 0 end) 员工种类为2的工资总额
from 表 group by department
- 2楼网友:举杯邀酒敬孤独
- 2021-02-22 16:56
select id,count(*) from 表名 where id group by id;
下次记着给点分
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯