# @aartii.py on Instagram

- **Type:** Video
- **Original URL:** https://www.instagram.com/p/DSh73lPDba3
- **Gondola URL:** https://gondola.cc/posts/59916250-aartiipy-instagram
- **Thumbnail:** https://img.gondola.cc/tr:w-,h-,fo-auto/postThumbnails/327b3af059.jpg
- **Posted:** 2025-12-21T15:20:04.000+00:00
- **Account Owner:** Aarti Sinha (@aartii.py) — https://gondola.cc/aartii.py

## Caption

Day 3/7 - SQL Challenge 🎯
TODAY'S QUESTION:
Find all products that have never been ordered.
TABLES:
Products (id, product_name, price)
Orders (id, customer_id, order_date)
Order_Items (id, order_id, product_id, quantity)
THE SOLUTION:
SELECT p.product_name
FROM Products p
LEFT JOIN Order_Items oi ON p.id = oi.product_id
WHERE oi.product_id IS NULL;
WHY THIS WORKS:
LEFT JOIN keeps ALL products (even without matches)
Products without orders have NULL in Order_Items columns
WHERE oi.product_id IS NULL filters to only those products
COMMON MISTAKES:
❌ Using INNER JOIN (only returns ordered products)
❌ Using WHERE oi.order_id = NULL (should be IS NULL)
❌ Not understanding LEFT JOIN vs INNER JOIN difference
ALTERNATIVE (using NOT IN):
SELECT product_name
FROM Products
WHERE id NOT IN (
 SELECT DISTINCT product_id
  FROM Order_Items
  WHERE product_id IS NOT NULL
);
ALTERNATIVE (using NOT EXISTS):
SELECT product_name
FROM Products p
WHERE NOT EXISTS (
 SELECT 1
  FROM Order_Items oi
  WHERE oi.product_id = p.id
);
WHY THIS IS ASKED:
Tests understanding of:
LEFT JOIN behavior
NULL handling
Business logic (finding missing data)
INTERVIEW TIP:
When asked "find records that DON'T have something," think:
LEFT JOIN + WHERE NULL
NOT IN
NOT EXISTS
Day 3/7 complete ✅
Which approach do you prefer?
#SQLChallenge #Day3 #Joins #DataScience #SQL LeftJoin

## Stats

- **Views:** 10,758
- **Likes:** 531
- **Shares:** 0
- **Comments:** 18

## Tags

sqlchallenge, day3, sql, joins, datascience

---
Copyright (c) Gondola