Analytic Functions - 분석함수 예제 (rollup, cube, grouping sets)
1. 예제 테이블 생성
create table used_car(
maker varchar2(100), -- 제조사
model varchar2(100), -- 모델명
colour varchar2(100), -- 차량색깔
price number -- 가격
);
2. 예제 데이타 생성
insert into used_car( maker, model, colour, price )
values('1.현대','그랜저','검정',2000);
insert into used_car( maker, model, colour, price )
values('1.현대','그랜저','쥐색',2100);
insert into used_car( maker, model, colour, price )
values('1.현대','그랜저','흰색',2200);
insert into used_car( maker, model, colour, price )
values('1.현대','소나타','검정',1500);
insert into used_car( maker, model, colour, price )
values('1.현대','소나타','쥐색',1600);
insert into used_car( maker, model, colour, price )
values('2.기아','K7','검정',2000);
insert into used_car( maker, model, colour, price )
values('2.기아','K7','쥐색',2100);
insert into used_car( maker, model, colour, price )
values('2.기아','K7','흰색',2200);
insert into used_car( maker, model, colour, price )
values('3.BMW','520','검정',2000);
insert into used_car( maker, model, colour, price )
values('3.BMW','520','쥐색',2100);
insert into used_car( maker, model, colour, price )
values('3.BMW','520','흰색',2200);
3. rollup
4. cube
5. grouping sets