Products Never Sold

Products Never Sold

Medium Programming Interview DBMS 23 views
Explanation Complexity

Problem Statement

Tables: Products(product_id, name), OrderItems(order_id, product_id). Find products that never appear in OrderItems.

Input Format

SQL tables are described in the question.

Output Format

Write the SQL query.

Input / Output Format

Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.

Example Solution (Public)

Programming Interview
SELECT p.product_id, p.name
FROM Products p
LEFT JOIN OrderItems oi ON oi.product_id=p.product_id
WHERE oi.product_id IS NULL;

Official Solution Code

SELECT p.product_id, p.name
FROM Products p
LEFT JOIN OrderItems oi ON oi.product_id=p.product_id
WHERE oi.product_id IS NULL;
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.