Question

List all customers who bought copy paper but did not buy any other item.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,st...

List all customers who bought copy paper but did not buy any other item.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(select customer.customer_name from customer, order_details, orders, office_supplies where customer.customer_id = orders.customer_id, orders.order_id = order_details.order_id, office_supplies.item_id = order_details.item_id and office_supplies.item_name = "copy paper" )

MINUS

(select customer.customer_name from customer, order_details, orders, office_supplies where customer.customer_id = orders.customer_id, orders.order_id = order_details.order_id, office_supplies.item_id = order_details.item_id and office_supplies.item_name != "copy paper" )

We are taking the difference of these two output where first output is customer name who ordered copy paper and second one is customer name who order anything other than copy paper , which will be out desired result

Please comment for any clarification

Add a comment
Know the answer?
Add Answer to:
List all customers who bought copy paper but did not buy any other item.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,st...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT