문제를 이해하고 있다면 바로 풀이를 보면 됨
전체 코드로 바로 넘어가도 됨
마음대로 번역해서 오역이 있을 수 있음
Table: Cinema
| Column Name | Type |
|---|---|
| id | int |
| movie | varchar |
| description | varchar |
| rating | float |
id는 이 테이블의 고유 키이다.
각 행에는 영화 제목, 장르, 평점에 대한 정보가 포함되어 있다.
평점은 소수점 둘째 자리까지 표시되는 [0, 10] 범위의 부동 소수점 값이다.
ID가 홀수이고 설명이 "boring"이 아닌 영화를 찾는 솔루션을 작성해라.
결과 테이블은 평점이 높은 순서대로 내림차순으로 정렬되어야 한다.
Input:
Cinema table:
| id | movie | description | rating |
|---|---|---|---|
| 1 | War | great 3D | 8.9 |
| 2 | Science | fiction | 8.5 |
| 3 | irish | boring | 6.2 |
| 4 | Ice song | Fantacy | 8.6 |
| 5 | House card | Interesting | 9.1 |
Output:
| id | movie | description | rating |
|---|---|---|---|
| 5 | House card | Interesting | 9.1 |
| 1 | War | great 3D | 8.9 |
Explanation:
홀수 ID를 가진 영화가 세 편 있다. 1, 3, 5이다. ID가 3인 영화는 "boring"이므로 포함하지 않는다.
-- Write your PostgreSQL query statement below
select *
from cinema
where id % 2 = 1
and description != 'boring'
order by rating desc