[TIL]_2025.03.14 본캠프 26일차 (1): 코드카타 SQL

JIYUU·2025년 3월 14일

77번. [Recyclable and Low Fat Products]
(https://leetcode.com/problems/recyclable-and-low-fat-products/)

select product_id
from products
where low_fats = True and recyclable = True

78번. [Find Customer Referee]
(https://leetcode.com/problems/find-customer-referee/)

select name
from customer
where referee_id is null or referee_id != 2

79번. [Big Countries]
(https://leetcode.com/problems/big-countries/description/)

select name, population, area
from world
where area >= 3000000 or population >= 25000000

80번. [Article Views I]
(https://leetcode.com/problems/article-views-i/description/)

  • autohr id = viewer_id이면 동일인이다
select distinct author_id as id
from views
where author_id = viewer_id
order by id asc

81번. [Invalid Tweets]
(https://leetcode.com/problems/invalid-tweets/description/)

  • 'strictly greater than 15' = 15보다 큰, 즉 16이상
select tweet_id
from tweets
where char_length(content) > 15
  • char_length() : Python의 len()처럼 문자의 개수를 세는 함수
  • length() : 문자의 byte 수를 계산하는 함수

82번. [Replace Employee ID With The Unique Identifier]
(https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/description/)

select eu.unique_id, e.name
from employees e
left join employeeUNI eu
on e.id = eu.id

83번. [Product Sales Analysis I]
(https://leetcode.com/problems/product-sales-analysis-i/)

select p.product_name, s.year, s.price
from sales s
join product p
on s.product_id = p.product_id

0개의 댓글