▶ 2021.10월에 있었던 BMW Ladies Championship 경기 내용으로 분석
create table BMW_2021(
name varchar2(100),
nation varchar2(100),
total number
);
insert into BMW_2021(name, nation, total)
values('고진영','한국',265);
insert into BMW_2021(name, nation, total)
values('정종','한국',266);
insert into BMW_2021(name, nation, total)
values('뉴질랜드선수','호주.뉴질랜드',271);
insert into BMW_2021(name, nation, total)
values('태종','한국',271);
insert into BMW_2021(name, nation, total)
values('세종','한국',271);
insert into BMW_2021(name, nation, total)
values('문종','한국',271);
insert into BMW_2021(name, nation, total)
values('단종','한국',272);
insert into BMW_2021(name, nation, total)
values('세조','한국',272);
insert into BMW_2021(name, nation, total)
values('America1','미국',273);
insert into BMW_2021(name, nation, total)
values('예종','한국',274);
insert into BMW_2021(name, nation, total)
values('America2','미국',274);
insert into BMW_2021(name, nation, total)
values('태국선수','태국',275);
insert into BMW_2021(name, nation, total)
values('호주선수','호주.뉴질랜드',275);
select BMW_2021.*
, count(*) over (partition by nation) as 나라별인원수
, rank() over(order by total) as 전체랭킹
, rank() over(partition by nation order by total) as 나라별랭킹
, avg(total) over (partition by nation) as 나라별평균타수
, min(total) over (partition by nation) as 나라별_최고점수
, max(name) keep(dense_rank first order by total) over (partition by nation) 나라별최고점수선수
from BMW_2021
order by nation, name
;
select nation,
max(name||' / '||total) keep(dense_rank first ORDER by total) 최고점수선수
from BMW_2021
group by nation
;
'Oracle' 카테고리의 다른 글
인덱스 일체형 테이블(Index-Organized Table) (1) | 2021.10.07 |
---|---|
오라클 트리거, trigger 정리 (2) | 2021.09.29 |
[모음] 유용한 사이트들 (0) | 2021.09.28 |
Merge Into 구문 (0) | 2021.09.27 |
날짜 관련 함수 모음 및 예제 (0) | 2021.09.27 |