Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Based upon the contents of the BOOKS table, write a query which will retrieve

ID: 3554127 • Letter: 1

Question




1) Based upon the contents of the BOOKS table, write a query which will retrieve all books published in 2001. Run the query and include the returned results.


2)Based upon the BOOKS table, write a query which will retrieve all book titles that are in the Business or Computer category and have a retail price of more than $35.00. Run the query and include the returned results.


3) Based upon the BOOKS table, write a query that will retrieve all books stored in the BOOKS table with Pubid 1 or 2 or that have a retail price of atleast $42.00. Run the query and include the returned results.


4) Based upon the contents of the ORDERS table, write a query which will display only those orders shipped to the zipcode zone that begins with 323. Run the query and include the returned results.


5) Based upon the CUSTOMERS table, write a query which will display the name of each customer in lower case characters.    Run the query and include the returned results.


6) Based upon the contents of the BOOKS table, write a query that will return the number of different publishers represented in the table. Run the query and include the returned results.


7) Based upon the BOOKS table, write a query which will display the retail price of the most expensive book provided by publisher 3. Run the query and include the returned results.



ISBN TITLE PUBDATE PUBID COST RETAIL CATEGORY 1059831198 BODYBUILD IN 10 MINUTES A DAY 21-JAN-01 4 18.75 30.95 FITNESS 0401140733 REVENGE OF MICKEY 14-DEC-01 1 14.2 22 FAMILY LIFE 4981341710 BUILDING A CAR WITH TOOTHPICKS 18-MAR-02 2 37.8 59.95 CHILDREN 8843172113 DATABASE IMPLEMENTATION 04-JUN-99 3 31.4 55.95 COMPUTER 3437212490 COOKING WITH MUSHROOMS 28-FEB-00 4 12.5 19.95 COOKING 3957136468 HOLY GRAIL OF ORACLE 31-DEC-01 3 47.25 75.95 COMPUTER 1915762492 HANDCRANKED COMPUTERS 21-JAN-01 3 21.8 25 COMPUTER 9959789321 E-BUSINESS THE EASY WAY 01-MAR-02 2 37.9 54.5 COMPUTER 2491748320 PAINLESS CHILD-REARING 17-JUL-00 5 48 89.95 FAMILY LIFE 0299282519 THE WOK WAY TO COOK 11-SEP-00 4 19 28.75 COOKING 8117949391 BIG BEAR AND LITTLE DOVE 08-NOV-01 5 5.32 8.95 CHILDREN 0132149871 HOW TO GET FASTER PIZZA 11-NOV-02 4 17.85 29.95 SELF HELP 9247381001 HOW TO MANAGE THE MANAGER 09-MAY-99 1 15.4 31.95 BUSINESS 2147428890 SHORTEST POEMS 01-MAY-01 5 21.85 39.95 LITERATURE

Explanation / Answer


--1) Based upon the contents of the BOOKS table, write a query which will retrieve all books published in 2001. Run the query and include the returned results.

SELECT *

FROM books

WHERE pubdate BETWEEN '01-JAN-2001' AND '31-DEC-2001';


--2)Based upon the BOOKS table, write a query which will retrieve all book titles that are in the Business or Computer category and have a retail price of more than $35.00. Run the query and include the returned results.

SELECT distinct title

FROM books

WHERE (UPPER(category) = 'BUSINESS'

OR UPPER(category) = 'COMPUTER')

AND retail > 35;


--3) Based upon the BOOKS table, write a query that will retrieve all books stored in the BOOKS table with Pubid 1 or 2 or that have a retail price of atleast $42.00. Run the query and include the returned results.

SELECT *

FROM books

WHERE pubid in (1, 2)

OR retail >= 42;


--4) Based upon the contents of the ORDERS table, write a query which will display only those orders shipped to the zipcode zone that begins with 323. Run the query and include the returned results.

SELECT *

FROM ORDERS

WHERE zipcode like '323%';


--5) Based upon the CUSTOMERS table, write a query which will display the name of each customer in lower case characters. Run the query and include the returned results.

SELECT LOWER(name)

FROM customers;


--6) Based upon the contents of the BOOKS table, write a query that will return the number of different publishers represented in the table. Run the query and include the returned results.

SELECT COUNT(DISTINCT pubid)

FROM books;


--7) Based upon the BOOKS table, write a query which will display the retail price of the most expensive book provided by publisher 3. Run the query and include the returned results.

SELECT MAX(retail)

FROM books

WHERE pubid = 3;