Interview Questions/SQL/Recyclable and Low Fat Products

Recyclable and Low Fat Products

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Recyclable and Low Fat Products

You have a Products table. Each product has two flags: low_fats and recyclable, each either 'Y' (yes) or 'N' (no). Write a SQL query to find the IDs of products that are both low fat AND recyclable. Return the result in any order.

Examples

Example 1

Only products 1 and 3 have both low_fats='Y' and recyclable='Y'.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql