반응형
이런..... 이런게 혼동 될 줄이야.. -ㅇ-
저량의 데이터에서야 그냥 보면 되지만.. 대량의 데이터로 아이체크가 잘 안 될 때는..
실수를 저질렀을 때 눈치 채지 못 할 수도 있다..
아주~ 잠시 혼동을 한게 있는데.. SUM 과 COUNT 의 차이점... 나 요즘 왜 이러나.. =ㅁ=
결과는
저량의 데이터에서야 그냥 보면 되지만.. 대량의 데이터로 아이체크가 잘 안 될 때는..
실수를 저질렀을 때 눈치 채지 못 할 수도 있다..
아주~ 잠시 혼동을 한게 있는데.. SUM 과 COUNT 의 차이점... 나 요즘 왜 이러나.. =ㅁ=
with test as
( select 'a' as col1,'1' as b from dual
union all
select 'a' as col1,'2' as b from dual
union all
select 'a' as col1,'3' as b from dual
union all
select 'b' as col1,'1' as b from dual
union all
select 'b' as col1,'2' as b from dual
union all
select 'b' as col1,'3' as b from dual
union all
select 'b' as col1,'4' as b from dual
)
select col1,sum(b),count(b) from test
group by col1;
( select 'a' as col1,'1' as b from dual
union all
select 'a' as col1,'2' as b from dual
union all
select 'a' as col1,'3' as b from dual
union all
select 'b' as col1,'1' as b from dual
union all
select 'b' as col1,'2' as b from dual
union all
select 'b' as col1,'3' as b from dual
union all
select 'b' as col1,'4' as b from dual
)
select col1,sum(b),count(b) from test
group by col1;
결과는
COL1 SUM(B) COUNT(B)
a 6 3
b 10 4
a 6 3
b 10 4
반응형
댓글