Welcome Back

Google icon Sign in with Google
OR
I agree to abide by Pharmadaily Terms of Service and its Privacy Policy

Create Account

Google icon Sign up with Google
OR
By signing up, you agree to our Terms of Service and Privacy Policy
Instagram
youtube
Facebook

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: