coding/sql 코딩테스트

[리트코드] 620. Not Boring Movies

임이레 2025. 2. 15. 15:49

 

select id
    , movie
    , description
    , rating
from (
    select case when 
            mod(id,2) = 1 then id end as id 
            ,movie 
            ,description 
            ,rating 
    from Cinema ) as t 
where id is not null and description <> 'boring'
order by rating desc ;

 

[풀이과정] 

 

1. id 가 홀수인 table 을 서브쿼리로 먼저 만든다.

2. 홀수인 id 에서  description이 boring 을 포함하고 있지 않도록 조건을 설정 

3. rating 기준으로 내림차순 

 

 

그리 복잡하지 않은 문제였다..!