SQL Challenge: Find Customers with No Orders

🧠 SQL Challenge 4/100 (IN 🆚 EXISTS) 🚀 🚀 Find customers who never placed any order 👉 Return: customer_id, name ⚠️ Catch There is a NULL in Orders.customer_id A very common approach will return 0 rows 😶 🔥 Caption This looks like a basic question… but one NULL breaks most solutions. If your query uses NOT IN, double check it 👀 Do you know the correct way? Drop your answer 👇 #SQL #DataEngineering #LearnSQL #Analytics #TechCareers

  • No alternative text description for this image

Select c.name from customer c where c.customer_id not in (select customer_id from order);

Like
Reply

SELECT * FROM CUSTOMER c WHERE NOT EXISTS ( SELECT 1 FROM ORDERS o WHERE c.CUSTOMER_ID = o. CUSTOMER_ID)

See more comments

To view or add a comment, sign in

Explore content categories