Find products that have no reviews

Quick Overview

Write a SQL query that returns every product with no matching row in a reviews table, sorted by product ID. It tests anti-joins with LEFT JOIN and IS NULL or NOT EXISTS, picking a column that is never NULL in a real match, and the NULL trap in NOT IN.

Find products that have no reviews

Company: Sap

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

`Products` lists the catalog and `Reviews` holds customer reviews, each tied to one product. Find all products in `Products` with no review in `Reviews`. Return `product_id`, `product_name`, `category`, and `price`, ordered by `product_id` ascending. If every product has a review, return an empty result. ```hint Spotting the missing match Pick a way to keep products that have no matching review, then decide which column reliably tells you that no match happened. ``` ### Input Table(s) `Products` | Column | Type | Meaning | |---|---|---| | product_id | INT, PRIMARY KEY | Unique ID of the product | | product_name | VARCHAR(100), NOT NULL | Product name | | category | VARCHAR(50), nullable | Product category | | price | DECIMAL(10,2), nullable | List price | Key: `product_id`. `Reviews` | Column | Type | Meaning | |---|---|---| | review_id | INT, PRIMARY KEY | Unique ID of the review | | product_id | INT, FOREIGN KEY to `Products.product_id` | Product the review is about | | reviewer_name | VARCHAR(100), nullable | Name of the reviewer | | rating | INT, nullable | Rating from 1 to 5 | | review_date | DATE, nullable | Day the review was posted | Key: `review_id`. A product can have any number of reviews. ### Output Contract - Columns, in this order: `product_id`, `product_name`, `category`, `price`. - One row per product that no `Reviews` row references. - Order by `product_id` ascending. `product_id` is unique, so the order is fully determined. - Return `category` and `price` as stored, including `NULL`. No rounding is applied. ### Example Input `Products`: | product_id | product_name | category | price | |---|---|---|---| | 1 | Wireless Mouse | Electronics | 24.99 | | 2 | Desk Lamp | Home | 39.50 | | 3 | Notebook | Stationery | 3.25 | | 4 | USB Cable | Electronics | NULL | | 5 | Water Bottle | NULL | 12.00 | Input `Reviews`: | review_id | product_id | reviewer_name | rating | review_date | |---|---|---|---|---| | 101 | 1 | Ana | 5 | 2024-03-01 | | 102 | 1 | Ben | 4 | 2024-03-04 | | 103 | 3 | Chloe | 2 | 2024-03-07 | | 104 | 5 | Dev | 3 | 2024-03-09 | Expected output: | product_id | product_name | category | price | |---|---|---|---| | 2 | Desk Lamp | Home | 39.50 | | 4 | USB Cable | Electronics | NULL | Products 1, 3 and 5 each have at least one review, so they are excluded (product 5 is excluded even though its category is `NULL`). Products 2 and 4 have none, and product 4 is returned with its `NULL` price as stored. ### Constraints and Clarifications - `Products` has at most 10,000 rows, `Reviews` at most 100,000 rows. - `rating` is an integer between 1 and 5. - Each review references a valid `product_id` in `Products`. - A product counts as reviewed when at least one `Reviews` row references it, whatever its rating or date. - `category` and `price` can be `NULL`. A product with missing values is returned like any other when it has no review. - A product with several reviews is still excluded once; the result never repeats a product.

Overview: Write a SQL query that returns every product with no matching row in a reviews table, sorted by product ID. It tests anti-joins with LEFT JOIN and IS NULL or NOT EXISTS, picking a column that is never NULL in a real match, and the NULL trap in NOT IN.

Sap logo
Sap
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

Products lists the catalog and Reviews holds customer reviews, each tied to one product. Find all products in Products with no review in Reviews. Return product_id, product_name, category, and price, ordered by product_id ascending. If every product has a review, return an empty result.

Input Table(s)

Products

ColumnTypeMeaning
product_idINT, PRIMARY KEYUnique ID of the product
product_nameVARCHAR(100), NOT NULLProduct name
categoryVARCHAR(50), nullableProduct category
priceDECIMAL(10,2), nullableList price

Key: product_id.

Reviews

ColumnTypeMeaning
review_idINT, PRIMARY KEYUnique ID of the review
product_idINT, FOREIGN KEY to Products.product_idProduct the review is about
reviewer_nameVARCHAR(100), nullableName of the reviewer
ratingINT, nullableRating from 1 to 5
review_dateDATE, nullableDay the review was posted

Key: review_id. A product can have any number of reviews.

Output Contract

  • Columns, in this order: product_id , product_name , category , price .
  • One row per product that no Reviews row references.
  • Order by product_id ascending. product_id is unique, so the order is fully determined.
  • Return category and price as stored, including NULL . No rounding is applied.

Example

Input Products:

product_idproduct_namecategoryprice
1Wireless MouseElectronics24.99
2Desk LampHome39.50
3NotebookStationery3.25
4USB CableElectronicsNULL
5Water BottleNULL12.00

Input Reviews:

review_idproduct_idreviewer_nameratingreview_date
1011Ana52024-03-01
1021Ben42024-03-04
1033Chloe22024-03-07
1045Dev32024-03-09

Expected output:

product_idproduct_namecategoryprice
2Desk LampHome39.50
4USB CableElectronicsNULL

Products 1, 3 and 5 each have at least one review, so they are excluded (product 5 is excluded even though its category is NULL). Products 2 and 4 have none, and product 4 is returned with its NULL price as stored.

Constraints and Clarifications

  • Products has at most 10,000 rows, Reviews at most 100,000 rows.
  • rating is an integer between 1 and 5.
  • Each review references a valid product_id in Products .
  • A product counts as reviewed when at least one Reviews row references it, whatever its rating or date.
  • category and price can be NULL . A product with missing values is returned like any other when it has no review.
  • A product with several reviews is still excluded once; the result never repeats a product.