LeetCode (620) - funny movie

topic:

A city opened a new cinema, attract a lot of people came to see the movie. The cinema special attention to the user experience, there is a dedicated LED display board to do a movie recommendation, it announced the critics and movie-related described above.

As the director of the movie theater information, you need to write a SQL query to find all the videos described as non-boring (not boring) and id is an odd movie, please arrange results by grade rating.

For example, the following table cinema:

± ------------- ---------- -------- ± ± ± ---------- +
| the above mentioned id | Movie | the 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 |
± -------- ± ---------- ± ------------- ± ---------- +
for the above example, the correct output is as follows:

±--------±----------±-------------±----------+
| id | movie | description | rating |
±--------±----------±-------------±----------+
| 5 | House card| Interesting| 9.1 |
| 1 | War | great 3D | 8.9 |
±--------±----------±-------------±----------+

answer:

//1
select * from cinema where description!='boring' and mod(id,2)=1 order by rating desc;
//2
select * from cinema where description not like 'boring' and id%2=1 order by rating desc ;

Guess you like

Origin blog.csdn.net/Fly_Fly_Zhang/article/details/95307020