Skip to content

Commit 35fa83f

Browse files
authored
Added task 1757.
1 parent 2583d04 commit 35fa83f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
1757\. Recyclable and Low Fat Products
2+
3+
Easy
4+
5+
SQL Schema
6+
7+
Table: `Products`
8+
9+
+-------------+---------+
10+
| Column Name | Type |
11+
+-------------+---------+
12+
| product_id | int |
13+
| low_fats | enum |
14+
| recyclable | enum |
15+
+-------------+---------+
16+
product_id is the primary key for this table.
17+
low_fats is an ENUM of type ('Y', 'N') where 'Y' means this product is low fat and 'N' means it is not.
18+
recyclable is an ENUM of types ('Y', 'N') where 'Y' means this product is recyclable and 'N' means it is not.
19+
20+
Write an SQL query to find the ids of products that are both low fat and recyclable.
21+
22+
Return the result table in **any order**.
23+
24+
The query result format is in the following example.
25+
26+
**Example 1:**
27+
28+
**Input:**
29+
30+
Products table:
31+
+-------------+----------+------------+
32+
| product_id | low_fats | recyclable |
33+
+-------------+----------+------------+
34+
| 0 | Y | N |
35+
| 1 | Y | Y |
36+
| 2 | N | Y |
37+
| 3 | Y | Y |
38+
| 4 | N | N |
39+
+-------------+----------+------------+
40+
41+
**Output:**
42+
43+
+-------------+
44+
| product_id |
45+
+-------------+
46+
| 1 |
47+
| 3 |
48+
+-------------+
49+
50+
**Explanation:** Only products 1 and 3 are both low fat and recyclable.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Write your MySQL query statement below
2+
# #Easy #Database #SQL_I_Day_1_Select #2022_05_03_Time_475_ms_(71.54%)_Space_0B_(100.00%)
3+
select product_id from Products
4+
where low_fats='Y' and recyclable='Y'

0 commit comments

Comments
 (0)