Question

For this assignment make sure that your submission includes your SQL queries and the results of...

For this assignment make sure that your submission includes your SQL queries and the results of the queries. You can use phpmyadmin, your own machine, the mysql> prompt.....whichever you wish!

Using the books database that we reviewed in class, give SQL queries to list the following:

1. customer names and addresses sorted by names ascending

2. customer names and order numbers and order amounts sorted by amounts descending

3. all authors that wrote a book that have the word 'computer' in the title

4. all customers that ordered a book that has a review

EXTRA CREDIT: 5. customer with the most orders (our best customer)

use books;

insert into customers values

(3, "Julie Smith", "25 Oak Street", "Airport West"),

(4, "Alan Wong", "1/47 Haines Avenue", "Box Hill"),

(5, "Michelle Arthur", "357 North Road", "Yarraville");

8 insert into orders values

(NULL, 3, 69.98, "2007-04-02"),

(NULL, 1, 49.99, "2007-04-15"),

(NULL, 2, 74.98, "2007-04-19"),

(NULL, 3, 24.99, "2007-05-01");

insert into books values

("0-672-31697-8", "Michael Morgan", "Java 2 for Professional Developers", 34.99),

("0-672-31745-1", "Thomas Down", "Installing Debian GNU/Linux", 24.99),

("0-672-31509-2", "Pruitt, et al.", "Teach Yourself GIMP in 24 Hours", 24.99),

("0-672-31769-9", "Thomas Schenk", "Caldera OpenLinux System Administration Unleashed", 49.99);

insert into order_items values

(1, "0-672-31697-8", 2),

(2, "0-672-31769-9", 1),

(3, "0-672-31769-9", 1),

(3, "0-672-31509-2", 1),

(4, "0-672-31745-1", 3);

insert into book_reviews values

("0-672-31697-8", "Morgan's book is clearly written and goes well beyond most of the basic Java books out there.");

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

1.

Select Name,Address from Customers order by Name;

2.

Select c.Name,o.OrderID,o.Amount from Customers c inner join Orders o on c.CustomerID = o.CustomerID order by o.Amount;

3.

Select Author from Books where title like '%computer%' ;

4.

Select c.Name from Customers c inner join Orders o on c.CustomerID = o.CustomerID inner join Order_Items ot on o.OrderID = ot.OrderID inner join Book_Reviews br on ot.ISBN = br.ISBN ;

EXTRA CREDIT: 5.

select c.Name from Orders o, Customers c where o.CustomerID = c.CustomerID and o.CustomerID IN (Select CustomerID from Orders group by CustomerID having count(*) = (Select count(*) from Orders o group by o.CustomerID order by count(*) desc limit 1))

Add a comment
Know the answer?
Add Answer to:
For this assignment make sure that your submission includes your SQL queries and the results of...
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
  • Part I. Create a library check-out database using Microsoft SQL Server that stores data about books,...

    Part I. Create a library check-out database using Microsoft SQL Server that stores data about books, patrons, and the check-out process. Books (BookID, BookName, Author, YearPublished) Patrons (PatronsID, PatronsName, PatronsAddress, PatronsBirthday) CheckInOut (TransactionID, PatronID, BookID, CheckOutDate, NumDay, ReturnDate, Late, Fees, Paid) - the NumDay field contains the number of days patrons can keep the book, if the return date is over the number of day, then the Late field will have a Y value and a fee of $1.00 per...

  • Answer the following questions using mysql. Please show screenshots to make sure the queries work...

    Answer the following questions using mysql. Please show screenshots to make sure the queries work. 1. Use a sub-query and the IN operator to find the number and name of each customer that placed an order on October 23, 2007. 2. Repeat step 2, but this time use the EXISTS operator in your answer. 3. Using a sub-query, find the number and name of each customer that did not place an order on October 23, 2007. 4. Using a sub-query,...

  • 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...

    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,...

  • SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and...

    SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and insert all the data. Show the SQL statements to create each table and show a representative SQL insert statement for the data in each table (i.e. you do not need to show insert statements for all the data). – For the remaining questions, assume that your SQL is part of a program function and the function provides the input needed for your SQL query....

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • E5.2 (no queries). Write the SQL queries that accomplish the following tasks in the HAFH Realty...

    E5.2 (no queries). Write the SQL queries that accomplish the following tasks in the HAFH Realty Company Property Manage- ment Database: E5.2a Display the SMemberID and SMemberName for all staff members. E5.2b Display the CCID, CCName, and CCIndustry for all corporate clients. E5.2c Display the BuildingID, BNoOfFloors, and the manager's MFName and MLName for all buildings. E5.2d Display the MFName, MLName, MSalary, MB- date, and number of buildings that the manager manages for all managers with a salary less than...

  • Given: Create table Book ( Book_id integer, Book_title varchar(50), Author varchar(50), Publish_date date, Type varchar(30), Edition...

    Given: Create table Book ( Book_id integer, Book_title varchar(50), Author varchar(50), Publish_date date, Type varchar(30), Edition number, Quantity number, Primary key (Book_id) ); insert into Book values (1,'The Old Man and the Sea','Hemingway' ,date '1978-1-1','hardcopy',3,2); insert into Book values (2,'The Old Man and the Sea','Hemingway' ,date '1979-1-1','hardcopy',4,1); insert into Book values (3,'The Old Man and the Sea','Hemingway' ,date '1980-1-1', 'hardcopy',5,10); insert into Book values (4,'A Farewell to Arms','Hemingway' ,date '1986-1-1','hardcopy',2,18); insert into Book values (5,'For Whom the Bell Tolls','Hemingway' ,date...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • Use the SQL statements provided to create your tables. Write one SQL statement for each of...

    Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...

  • 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...

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