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 기준으로 내림차순
그리 복잡하지 않은 문제였다..!
'coding > sql 코딩테스트' 카테고리의 다른 글
[프로그래머스] 오프라인/온라인 판매 데이터 통합하기 (0) | 2025.03.25 |
---|---|
[리트코드] 1174. Immediate Food Delivery II (0) | 2025.02.20 |
[리트코드] 619. Biggest Single Number (0) | 2025.02.15 |
[리트코드] Investments in 2016 (0) | 2025.02.11 |
[리트코드] 184. Department Highest Salary (0) | 2025.02.07 |