LeetCode - Problems - Database - 620. Not Boring Movies
더보기
Given SQL Schema
Create table If Not Exists cinema (id int, movie varchar(255), description varchar(255), rating float(2, 1))
Truncate table cinema
insert into cinema (id, movie, description, rating) values ('1', 'War', 'great 3D', '8.9')
insert into cinema (id, movie, description, rating) values ('2', 'Science', 'fiction', '8.5')
insert into cinema (id, movie, description, rating) values ('3', 'irish', 'boring', '6.2')
insert into cinema (id, movie, description, rating) values ('4', 'Ice song', 'Fantacy', '8.6')
insert into cinema (id, movie, description, rating) values ('5', 'House card', 'Interesting', '9.1')
Problem Description
X city opened a new cinema, many people would like to go to this cinema.
The cinema also gives out a poster indicating the movies' ratings and descriptions.
Please write a SQL query to output movies with an odd-numbered ID and a description that is not 'boring'.
Order the result by rating.
My Solution (Oracle)
SELECT *
FROM cinema
WHERE MOD(id, 2) = 1
AND description != 'boring'
ORDER BY rating DESC;solution
'Problem solving > DataBase' 카테고리의 다른 글
[LeetCode] 182. Duplicate Emails (Oracle) (0) | 2021.01.14 |
---|---|
[LeetCode] 1179. Reformat Department Table (Oracle) (0) | 2021.01.11 |
[LeetCode] 627. Swap Salary (Oracle) (0) | 2021.01.09 |
[LeetCode] 595. Big Countries (Oracle) (0) | 2021.01.08 |