DB - 영화 정보 데이터 실습 - 1

박근수·2024년 1월 29일

DB

목록 보기
7/10

데이터 정보



문제

Q1. 영화 정보중 영문 제목이 없는 데이터 조회

//1
select * from movie where eng_title is null or trim(eng_title) = '';

//2
select * from movie where eng_title is null or length(trim(eng_title)) = 0;

Q2. 2001년도에 개봉한 한국 액션 영화 조회

select * from movie where country = '한국' 
					and pub_year = 2001 
    				and genre like '%액션%';

Q3. 싸이더스가 2020년도에 개봉한 영화 감독의 출생년도 조회

select birth from actor where domain = '감독' and name in(
      select director from movie where production like '%싸이더스%' and pub_year = 2020
    );

Q4. 영화인 정보에서 직업을 중복없이 조회

//1
select distinct domain from actor where domain is not null and trim(domain) <> '';

//2
select domain from actor where domain is not null and trim(domain) <> ''
group by domain;

Q5. 영화 감독의 국가가 독일이고 2020년 이후에 개봉한 영화의 제목, 감독, 개봉일자, 장르를 최근 개봉일자 순으로 조회

select m.title, m.director, m.pub_year, m.genre
    from movie m
         join actor a on (m.director = a.name and a.domain = '감독')
         where m.pub_year > 2020 and a.country = '독일'
order by  m.pub_year desc;

Q6. 시카고에서 진행하는 축제중에서 영문 제목이 없는 경우 한글 제목으로 보여주며, 장르가 없는 경우 기타로 표시, 홈페이지가 없는 경우 '홈페이지 없음'으로 조회

select f.title,
        case
            when ifnull(f.eng_title, '') = '' then f.title
            else f.eng_title
        end as eng_title
       , f.continent, f.country, f.city,
         case
            when ifnull(f.gerne, '') = '' then '기타'
            else f.gerne
         end as gerne
       ,f.important_flag,
          case
              when ifnull(f.homepage, '') = '' then '홈페이지 없음'
              else f.homepage
          end as homepage
from festival f where country = '미국' and city = '시카고';

Q7. 영화 상영관 회사별로 좌석주가 가장 많은 값을 구하고 순서대로 조회

select row_number() over (order by max(seat_count) desc) as ranking,
       biz_name, max(seat_count) as max_seat_count
from screen where biz_name is not null and trim(biz_name) <> ''
group by biz_name order by max_seat_count desc;

Q8. 국가별 영화 정보의 개수를 조회

select case 
         when ifnull(country, '') = '' then '국가 미상'
         else country
       end as country
       , count(*) as movie_count from movie group by country order by  movie_count desc;

Q9. CGV 극장중 스크린 수가 가장 많은 극장의 순위를 5위까지 조회

select * from screen where biz_name like '%CJ%' order by screen_count desc limit 5;

Q10. 스크린 수가 가장 많은 극장 이름 조회

select * from screen where screen_count in(
    select max(screen_count) from screen
    );

profile
개발블로그

0개의 댓글