๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Basic/[SQL] Leetcode ํ’€์ด๋…ธํŠธ

[LeetCode | Easy] 1757. Recyclable and Low Fat Products

๐Ÿ”ป ๋ฌธ์ œ ๋งํฌ

https://leetcode.com/problems/recyclable-and-low-fat-products/?envType=study-plan&id=sql-i 

 

Recyclable and Low Fat Products - LeetCode

Can you solve this real interview question? Recyclable and Low Fat Products - Table: Products +-------------+---------+ | Column Name | Type | +-------------+---------+ | product_id | int | | low_fats | enum | | recyclable | enum | +-------------+---------

leetcode.com

 

๐Ÿ”ป ๋ฌธ์ œ ํŒŒ์•…

low fat์ด๊ณ , recyclable ํ•œ ์ œํ’ˆ์„ ์กฐํšŒํ•ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

์ฆ‰, ์กฐ๊ฑด์— ๋งž๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•˜๋ฉด ๋œ๋‹ค.

 

๐Ÿ”ป ๋ฌธ์ œ ํ•ด๊ฒฐ

  • SELECT~ FROM ์œผ๋กœ ์กฐํšŒํ•  ํ–‰์„ ์„ ํƒ
  • WHERE๋กœ ์กฐ๊ฑด ์ž…๋ ฅ
    • low_fats์™€ recyclable ์ปฌ๋Ÿผ ๋ชจ๋‘ Y ์—ฌ์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— and๋กœ ๋‘ ์กฐ๊ฑด์„ ๋ชจ๋‘ ๋งŒ์กฑํ•˜๋„๋ก ์ž‘์„ฑํ•ด์ค€๋‹ค.
SELECT product_id
FROM Products
WHERE low_fats = 'Y' and recyclable = 'Y'