You are a data analyst at a growing e-commerce company. The product team wants to understand which products in the catalog have never caught the attention of any shopper — specifically, products that no user has ever added to their wishlist. These products may need better marketing, a price adjustment, or could be candidates for removal from the catalog altogether. You have access to two tables: products , which contains product_id , product_name , and category ; and wishlists , which records each time a user saves a product, containing wishlist_id , user_id , and product_id (a foreign key referencing the products table). A product that has never been wishlisted will simply have no matching rows in the wishlists table. Return all products that have never been added to any wishlist. Include the product name and category in your output. Sort the results alphabetically by product name . Hint: This is a classic anti-join pattern. Use a LEFT JOIN from products to wishlists and filter for rows where the joined product_id from the wishlists table IS NULL . A common pitfall is using an INNER JOIN or NOT IN with a subquery — while NOT IN can work, it behaves unexpectedly if the subquery returns any NULL values. The LEFT JOIN ... IS NULL approach is safer and more performant in PostgreSQL.
Table Setup (SQL Schema)
CREATE TABLE products (
product_id SERIAL PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
category VARCHAR(50) NOT NULL
);
CREATE TABLE wishlists (
wishlist_id SERIAL PRIMARY KEY,
user_id INT NOT NULL,
product_id INT NOT NULL REFERENCES products(product_id)
);
INSERT INTO products (product_name, category) VALUES
('Wireless Noise-Cancelling Headphones', 'Electronics'),
('Yoga Mat Pro', 'Sports'),
('Stainless Steel Water Bottle', 'Kitchen'),
('Mechanical Keyboard', 'Electronics'),
('Running Shoes X200', 'Sports'),
('Non-Stick Cookware Set', 'Kitchen'),
('Portable Bluetooth Speaker', 'Electronics'),
('Resistance Band Kit', 'Sports'),
('French Press Coffee Maker', 'Kitchen'),
('Smart LED Desk Lamp', 'Electronics');
INSERT INTO wishlists (user_id, product_id) VALUES
(101, 1),
(102, 1),
(103, 3),
(101, 4),
(104, 4),
(105, 5),
(102, 7),
(106, 7),
(103, 7),
(107, 10),
(101, 10),
(108, 3);