视图 A,下面例子简单,实际工作上比这复杂
select count(*) a from t_list t
group by t.id视图结果
a
1
1
2
3
4
5
5
6
6
7我要统计这个视图结果里 =1的数量,等于2的数量,依此类推
谢谢了
select count(*) a from t_list t
group by t.id视图结果
a
1
1
2
3
4
5
5
6
6
7我要统计这个视图结果里 =1的数量,等于2的数量,依此类推
谢谢了
from (
select count(*) a
from t_list t
group by t.id ) t1
group by t1.a;
select a,count(1)
from A
group by A
from t_list
,
SELECT LEVEL,COUNT(1) 数量 FROM t_list
CONNECT BY LEVEL<=T.CNT
GROUP BY LEVEL;
应该是<3,等于4,等于5,等于6,>7
看来那两种大小于的只能再查询一次视图了吧 ?
sum(case when a = 2 then 1 else 0 end) "a=2",
sum(case when a < 3 then 1 else 0 end) "a<1",
sum(case when a = 4 then 1 else 0 end) "a=4",
sum(case when a = 5 then 1 else 0 end) "a=5",
sum(case when a = 6 then 1 else 0 end) "a=6",
sum(case when a > 7 then 1 else 0 end) "a>7"
from temp
sum(case when a = 2 then 1 else 0 end) "a=2",
sum(case when a < 3 then 1 else 0 end) "a<1",
sum(case when a = 4 then 1 else 0 end) "a=4",
sum(case when a = 5 then 1 else 0 end) "a=5",
sum(case when a = 6 then 1 else 0 end) "a=6",
sum(case when a > 7 then 1 else 0 end) "a>7"
from temp
SELECT COUNT(1),COUNT(1) OVER(PARTITION BY COUNT(1))
FROM t_list t
group by t.id