Eco-healthy shelf picks — SQL
List the ids of products that pass both checks: little fat, and packaging that can be recycled.
SQL · Easy
The problem
Your shop wants an eco-healthy shelf: which products make the cut? Each product has two flags: whether it is low in fat, and whether its packaging is recyclable. Report the ids of the products that are both low in fat and recyclable.
The story
A grocery chain is setting up an eco-healthy shelf, and only products that tick both boxes make the cut: low in fat and in recyclable packaging. Each product carries a Y or N flag for each. Pull the ids of every product that qualifies.
What to return
- One column, product_id, with one row per qualifying product. Any order.
Constraints
- product_id is unique in Products
- low_fats and recyclable are each either 'Y' or 'N'
- Products has at most 12 rows in the examples
Example
- Input
Products(product_id, low_fats, recyclable)[10, "Y", "Y"][11, "N", "Y"][12, "Y", "N"][13, "Y", "Y"][14, "N", "N"][15, "N", "Y"]- Output
(product_id)[10][13]
Products 10 and 13 have both flags set to Y.