Instagram
youtube
Facebook
Twitter

Find Orders with No Payments

Find Orders with No Payments

Orders Table:



Customers Table:

Query Explanation:

  • We're using a LEFT JOIN from Orders to Payments:

    • This joins every order with its corresponding payment (if it exists).

  • WHERE p.OrderID IS NULL:

    • Filters only those orders that have no matching payment in the Payments table.

  • This gives us a list of all orders that were placed but not paid for.


SQL Query:

SELECT o.OrderID, o.CustomerID, o.OrderDate
FROM Orders o
LEFT JOIN Payments p ON o.OrderID = p.OrderID
WHERE p.OrderID IS NULL;


Output: