0
$\begingroup$

I have 3 tables with columns likes-

Customers(customer_id,  first_name, last_name,  age country)
Orders(order_id item,   amount, customer_id)
Shippings(shipping_id,  status, customer)

and I want to get the result - "All those customer who has to spend over $250 and their products isn't delivered"

SELECT Customers.first_name, Customers.last_name,
   Orders.amount, Shippings.status
FROM Customers
INNER JOIN Orders
    ON Customers.customer_id = Orders.customer_id
    INNER JOIN Shippings
        ON (Orders.customer_id = Shippings.customer)
        WHERE Shippings.status <> "Delivered"

Now, where should I use the WHERE statement, and how to get the desired output? WHERE Statement-

        WHERE Orders.amount > 250
$\endgroup$

1 Answer 1

0
$\begingroup$

This worked-

SELECT Customers.first_name, Customers.last_name,
Orders.amount, Shippings.status
FROM Customers
INNER JOIN Orders
    ON (Customers.customer_id = Orders.customer_id)

    INNER JOIN Shippings
        ON (Orders.customer_id = Shippings.customer)
        WHERE Shippings.status <> "Delivered"
        AND Orders.amount > 250
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.