Filter products that are both recyclable and low fat.
Problem
You are given a table of products. Each product has information including whether it is recyclable and whether it is low fat. Return the identifiers of all products that satisfy both of these conditions:
- the product is recyclable
- the product is low fat
The answer can be returned in any order.
Goal
Write a query that selects only the rows meeting both conditions and outputs the product ids.
Input Format
A table of products with at least these columns:
product_idlow_fatsrecyclable
Each of low_fats and recyclable uses a binary indicator.
Output Format
A result table with a single column:
product_id
Include only rows where low_fats = 'Y' and recyclable = 'Y'.
Constraints
- Return each qualifying
product_idonce. - The output order does not matter.
- This is a simple filtering query.
Example 1
Input
Products table: +-------------+----------+------------+ | product_id | low_fats | recyclable | +-------------+----------+------------+ | 0 | Y | N | | 1 | Y | Y | | 2 | N | Y | | 3 | Y | Y | +-------------+----------+------------+
Output
+-------------+ | product_id | +-------------+ | 1 | | 3 | +-------------+
Explanation
Only products 1 and 3 are both low fat and recyclable.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.