Question

Please help me on the SQL queries, thank you so much.

  1. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause.
  2. 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.
  3. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered, show the order number and order date. Use the OUTER JOIN keywords to join the tables. Sort the titles in alphabetical order.
  4. Write a query to show the gift a customer will receive if he or she orders Database Implementation.   Use either the WHERE clause or a JOIN keyword to join the tables.
  5. Write a query to show the profit of each book sold to Leila Smith. Calculate the profit by subtracting the cost from the paideach column in the orderitems table. Use the WHERE clause to the join the tables.

ORDERS CUSTOMERS |Order# Customer# Orderdate Shipdate meShipstreet Shipcity Shipstate Shipzip Shipcost Customer# Lastname Fir

SCRIPT:

CREATE TABLE warehouses
(wh_id NUMBER(2),
   location VARCHAR(12) );
INSERT INTO warehouses
VALUES (10, 'Boston');
INSERT INTO warehouses
VALUES (20, 'Norfolk');
INSERT INTO warehouses
VALUES (30, 'San Diego');
COMMIT;
Create Table Publisher2
(ID NUMBER(2),
Name VarCHAR2(23),
Contact VARCHAR2(15),
Phone VARCHAR2(12),
CONSTRAINT publisher2_pubid_pk PRIMARY KEY(id));
INSERT INTO PUBLISHER2
VALUES(1,'PRINTING IS US','TOMMIE SEYMOUR','000-714-8321');
INSERT INTO PUBLISHER2
VALUES(2,'PUBLISH OUR WAY','JANE TOMLIN','010-410-0010');
INSERT INTO PUBLISHER2
VALUES(3,'AMERICAN PUBLISHING','DAVID DAVIDSON','800-555-1211');
INSERT INTO PUBLISHER2
VALUES(4,'READING MATERIALS INC.','RENEE SMITH','800-555-9743');
INSERT INTO PUBLISHER2
VALUES(5,'REED-N-RITE','SEBASTIAN JONES','800-555-8284');
commit;
Create Table Publisher3
(ID NUMBER(2),
Name VarCHAR2(23),
Contact VARCHAR2(15),
Phone VARCHAR2(12),
CONSTRAINT publisher3_pubid_pk PRIMARY KEY(id));
INSERT INTO PUBLISHER3
VALUES(2,'PUBLISH OUR WAY','JANE TOMLIN','010-410-0010');
INSERT INTO PUBLISHER3
VALUES(3,'AMERICAN PUB','DAVID DAVIDSON','800-555-1211');
INSERT INTO PUBLISHER3
VALUES(6,'PRINTING HERE','SAM HUNT','000-714-8321');
INSERT INTO PUBLISHER3
VALUES(7,'PRINT THERE','CINDY TIKE','010-410-0010');
commit;
CREATE TABLE Employees (
EMPNO               NUMBER(4),
LNAME               VARCHAR2(20),
FNAME               VARCHAR2(15),
JOB                 VARCHAR2(9),
HIREDATE            DATE,
DEPTNO              NUMBER(2) NOT NULL,
MTHSAL                 NUMBER(7,2),
MGR                 NUMBER(4),
CONSTRAINT employees_empno_PK PRIMARY KEY (EMPNO));
INSERT INTO employees VALUES (7839,'KING','BEN', 'GTECH2','17-NOV-91',10,6000,NULL);
INSERT INTO employees VALUES (8888,'JONES','LARRY','MTech2','17-NOV-98',10,4200,7839);
INSERT INTO employees VALUES (7344,'SMITH','SAM','GTech1','17-NOV-95',20,4900,7839);
INSERT INTO employees VALUES (7355,'POTTS','JIM','GTech1','17-NOV-95',20,4900,7839);
INSERT INTO employees VALUES (8844,'STUART','SUE','MTech1','17-NOV-98',10,3700,8888);
COMMIT;

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

Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause.

Query: SELECT Title, Name, Contact FROM BOOKS b JOIN PUBLISHER p USING PubID;

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.

Query: SELECT FirstName, LastName FROM CUSTOMERS c, ORDERS o, ORDERITEMS oi, BOOKS b WHERE c.Customer# = o.Customer# and o.Order# = oi.Order# and oi.ISBN = b.ISBN and b.Title = 'Cooking';

Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered, show the order number and order date. Use the OUTER JOIN keywords to join the tables. Sort the titles in alphabetical order.

Query: SELECT b.Title, b.Cost, b.ISBN, o.Order#, o.OrderDate FROM BOOKS b OUTER JOIN ORDERITEMS oi ON oi.Order# and oi.ISBN = b.ISBN OUTER JOIN  ORDERS o ON o.Order# = oi.Order#;

NOTE: As per HOMEWORKLIB POLICY, I am allowed to answer only 3 questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...
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
  • Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order...

    Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order 1014. CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); INSERT INTO ORDERS VALUES (1000,1005,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('02-APR-09','DD-MON-YY'),'1201 ORANGE AVE', 'SEATTLE', 'WA', '98114' , 2.00); INSERT INTO ORDERS VALUES (1001,1010,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'), '114 EAST SAVANNAH', 'ATLANTA', 'GA', '30314', 3.00); INSERT INTO ORDERS VALUES (1002,1011,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'58...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DRO...

    oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DROP TABLE BOOKS; DROP TABLE PROMOTION; DROP TABLE AUTHOR; DROP TABLE CUSTOMERS; DROP TABLE PUBLISHER; CREATE TABLE Customers ( Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Email VARCHAR(40), Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#) ); INSERT INTO CUSTOMERS VALUES (1001, 'MORALES', 'BONITA', '[email protected]', 'P.O. BOX 651', 'EASTPOINT', 'FL', '32328', NULL, 'SE'); INSERT INTO CUSTOMERS VALUES...

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
ADVERTISEMENT