List the names of all customers who bought both envelopes and labels (either in the same order or different orders).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)
Answer.)
The query to the above question is as follows :
--Selecting DISTINCT Customer Names as the name can repeat
-- Also, joining all the tables as we have a primary key and a foreign key in all the tables from which data needs to be filtered
SELECT DISTINCT CUSTOMER_NAME FROM CUSTOMER C, OFFICE_SUPPLIES OS, ORDERS O, ORDER_DETAILS OD
WHERE C.CUSTOMER_ID=O.CUSTOMER_ID
AND O.ORDER_ID = OD.ORDER_ID
AND OS.ITEM_ID = OD.ITEM_ID
WHERE OS.ITEM_NAME IN ('ENVELOPS','LABELS');
For any doubts, queries, drop a comment below.
List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(...
List the names of the customer (or customers) who spent the greatest dollar amount in a single order.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)
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)
List all items sold by the company, sorted alphabetically by category and the alphabetically by item name. 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)
List each category, the name of the customer who has spent the most on items in that category, and the total amount of money that customer spent in that category.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)
Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...
Instructions Try to answer all the questions using what you have learned in class. Please make your query general not data related This schema is used for inventory management for an OEM Part Inventory p_id Name Cost Supplier Location 1 Traction motor 200 Melco Japan 2 Alternator 400 kato USA 3 HVAC 300 Melco Japan p_id Warehouse_id quantity 1 A1 100 2 A2 250 3 B1 300 Customer Model c_id Name Location CN Canada National Canada UP Union Pacific USA...
DROP TABLE IF EXISTS customers; DROP TABLE IF EXISTS orders; DROP TABLE IF EXISTS order_details; DROP TABLE IF EXISTS items; DROP TABLE IF EXISTS artists; DROP TABLE IF EXISTS employees; -- create tables CREATE TABLE customers ( customer_id INT , customer_first_name VARCHAR(20), customer_last_name VARCHAR(20) NOT NULL, customer_address VARCHAR(50) NOT NULL, customer_city VARCHAR(20) NOT NULL, customer_state CHAR(2) NOT NULL, customer_zip CHAR(5) NOT NULL, customer_phone CHAR(10) NOT NULL, customer_fax CHAR(10), CONSTRAINT customers_pk...
Seeking help/ explanation for a SQL question. 1.) How many different customers have made orders? Tables: CLOTHES ClOID, Type, Brand, Descript, Matrial, MadeInCountry, Size, Price, SID, POID) CUSTOMER (CustID, Cname, Cbirthdate, Cemail, Cstreet, Ccity, Cstate, Czip, CreditCard, CsignupDate) ORDER SHIPMENT (OrderShipiD, Ship:D, Po:D) PURORDER (POID, PurchaseDate, Shipoption, Quantity, CustID) SHIPMENT (ShipID, TrackingNum, Shipstreet, Shipcity, Shipstate, Shipzip, EstimateDeliveryDate, CustID) SUPPLIER (SID, Sname, Sstreet, scity, Sstate, Szip, Slicense) E-R Diagram: Implementation Model Quantity CLOTHES H SUPPLIER CUSTOMER Places 여 PURORDER Contains POID...