某城市開了一家新的電影院,吸引了很多人過來看電影。該電影院特別注意用戶體驗,專門有個 LED顯示板做電影推薦,上面公布著影評和相關電影描述。
作為該電影院的信息部主管,您需要編寫一個 SQL查詢,找出所有影片描述為非?boring?(不無聊)?的并且 id 為奇數?的影片,結果請按等級 rating 排列。
?
例如,下表 cinema:
+---------+-----------+--------------+-----------+
| ? 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 ? ? |
+---------+-----------+--------------+-----------+
對于上面的例子,則正確的輸出是為:
+---------+-----------+--------------+-----------+
| ? id ? ?| movie ? ? | ?description | ?rating ? |
+---------+-----------+--------------+-----------+
| ? 5 ? ? | House card| ? Interesting| ? 9.1 ? ? |
| ? 1 ? ? | War ? ? ? | ? great 3D ? | ? 8.9 ? ? |
+---------+-----------+--------------+-----------+
思路:按條件查即可。
select *
from cinema
where mod(id, 2) = 1 and description <> 'boring'
order by rating DESC;
?