Problem solving/DataBase

[LeetCode] 620. Not Boring Movies (Oracle)

Young_A 2021. 1. 10. 09:23

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