Filter products that are both recyclable and low fat.
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 answer can be returned in any order.
Write a query that selects only the rows meeting both conditions and outputs the product ids.
A table of products with at least these columns:
product_idlow_fatsrecyclableEach of low_fats and recyclable uses a binary indicator.
A result table with a single column:
product_idInclude only rows where low_fats = 'Y' and recyclable = 'Y'.
product_id once.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
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.