[1757_EASY] Recyclable and Low Fat Products

2022. 7. 31. 23:16·SQL/LeetCode

Table: Products

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| product_id  | int     |
| low_fats    | enum    |
| recyclable  | enum    |
+-------------+---------+
product_id is the primary key for this table.
low_fats is an ENUM of type ('Y', 'N') where 'Y' means this product is low fat and 'N' means it is not.
recyclable is an ENUM of types ('Y', 'N') where 'Y' means this product is recyclable and 'N' means it is not.

 

Write an SQL query to find the ids of products that are both low fat and recyclable.

Return the result table in any order.

The query result format is in the following example.

 

Example 1:

Input: 
Products table:
+-------------+----------+------------+
| product_id  | low_fats | recyclable |
+-------------+----------+------------+
| 0           | Y        | N          |
| 1           | Y        | Y          |
| 2           | N        | Y          |
| 3           | Y        | Y          |
| 4           | N        | N          |
+-------------+----------+------------+
Output: 
+-------------+
| product_id  |
+-------------+
| 1           |
| 3           |
+-------------+
Explanation: Only products 1 and 3 are both low fat and recyclable.

 

문제 조건 

low_fats, recyclable인 제품의 id를 출력하시오 

 

문제 풀이

SELECT product_id
FROM Products 
WHERE low_fats = 'Y' 
AND recyclable = 'Y'
저작자표시 (새창열림)

'SQL > LeetCode' 카테고리의 다른 글

[1789#_EASY] Primary Department for Each Employee  (0) 2022.07.31
[1777#_EASY] Product's Price for Each Store  (0) 2022.07.31
[1212#_MEDIUM]Team Scores in Football Tournament  (0) 2022.07.29
[1205#_MEDIUM] Monthly Transactions II  (0) 2022.07.26
[1741_EASY] Find Total Time Spent by Each Employee  (0) 2022.07.26
'SQL/LeetCode' 카테고리의 다른 글
  • [1789#_EASY] Primary Department for Each Employee
  • [1777#_EASY] Product's Price for Each Store
  • [1212#_MEDIUM]Team Scores in Football Tournament
  • [1205#_MEDIUM] Monthly Transactions II
소금깨
소금깨
  • 소금깨
    고군분투 인생살이
    소금깨
  • 전체
    오늘
    어제
    • 분류 전체보기 (328)
      • SQL (271)
        • 프로그래머스 (27)
        • LeetCode (198)
        • Hacker Rank (27)
        • Solve SQL (1)
        • 개념 (15)
      • 데이터 분석 (16)
        • 참고하며 공부하기 (14)
      • 기타 (15)
        • 통계 (14)
      • 오류 (6)
      • 인생살이 (0)
        • 리뷰 (0)
        • 일기 (0)
      • 中文 (0)
      • TABLEAU (3)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    패스트캠퍼스후기
    파이썬을활용한시계열데이터분석
    직장인자기계발
    해커랭크
    Hard
    SQL
    group by
    LeetCode
    solvesql
    시계열데이터분석
    MySQL
    easy
    직장인인강
    HACKER_RANK
    프리미엄
    패캠챌린지
    medium
    프로그래머스
    파이썬을활용한시계열데이터분석AtoZ올인원패키지Online
    패스트캠퍼스
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
소금깨
[1757_EASY] Recyclable and Low Fat Products
상단으로

티스토리툴바