관리 메뉴

물 만날 물고기

[LeetCode/MYSQL] - 620. Not Boring Movies 본문

DB & SQL/Leetcode

[LeetCode/MYSQL] - 620. Not Boring Movies

Lung Fish 2023. 6. 28. 01:28

🔍 예상 검색어

더보기

# 물만날물고기

# LeetCode

# SQL

# Not Boring Movies


해당 포스팅은 LeetCode/MYSQL "Not Boring Movies"에 대한 풀이를 정리하였습니다.

 

▶ 문제

Not Boring Movies - LeetCode

 

Not Boring Movies - LeetCode

Can you solve this real interview question? Not Boring Movies - Table: Cinema +----------------+----------+ | Column Name | Type | +----------------+----------+ | id | int | | movie | varchar | | description | varchar | | rating | float | +----------------

leetcode.com

 

▶ 내 정답

# Write your MySQL query statement below

-- Cinema
-- id, movie, description, rating                


-- odd-numbered ID
-- description that is not "boring"


SELECT id, movie, description, rating
FROM Cinema
WHERE MOD(id, 2) = 1 AND description != "boring"
ORDER BY rating DESC;

 

▶ 다른 사람 정답 (1)

# Write your MySQL query statement below
select * from Cinema where id % 2!=0 and description!="boring" order by rating desc;

 

▶ 다른 사람 정답 (2)

SELECT * 
FROM Cinema
WHERE id % 2 = 1 
AND description <> 'boring'
ORDER BY rating DESC;

 

▶ 총평

- 홀수 처리하는 방법 MOD를 사용하던지 %2 !=0 또는 %2 = 1을 선택

- description <> 'boring' 또는 escription != "boring" 

 

 

▼ 참고자료

No. 내용 비고
1 Not Boring Movies - LeetCode dipesh_12
2 Clear implementation in MS SQL | MySQL | Oracle - Not Boring Movies - LeetCode younus_baig
3 - -
4 - -
5 - -

▼ 복습/히스토리

더보기
No. 복습일 비고
1    
2    
3    
4    
5    

- 작성코드

--

 



 

'DB & SQL > Leetcode' 카테고리의 다른 글

[LeetCode/MYSQL] - 182. Duplicate Emails  (0) 2023.06.29
[LeetCode/MYSQL] - 175. Combine Two Tables  (0) 2023.06.28
[LeetCode/MYSQL] - 595. Big Countries  (0) 2023.06.28