Init Commit and Qs A-U

This commit is contained in:
Noah L. Schrick 2022-09-12 18:19:22 -05:00
commit 00d5f5e2d4
3 changed files with 127 additions and 0 deletions

BIN
Case-Study-2.docx Normal file

Binary file not shown.

59
README.md Normal file
View File

@ -0,0 +1,59 @@
# Case Study 2
## Instructions
- Use the MDC\_CH02 database
- Answer MARCIA'S DRY-CLEANING QUESTIONS at the end of the chapter (Questions A-U)
- Deliver a single sql file, along with a document that contains all the content from the sql file
- Each query should start with a comment line that looks like:
/* *** CS2-\<Q> *** \*/
Example for Question A:
/* *** CS2-A*** */
- Do not include the result table unless specifically directed to
- Include at least one line of white space between answers
## Questions A-U
A.) Show all data in each of the tables.
B.) List the LastName, FirstName, and Phone of all customers.
C.) List the LastName, FirstName, and Phone for all customers with a FirstName of Nikki.
D.) List the LastName, FirstName, Phone, DateIn, and DateOut of all orders in excess of $100.00.
E.) List the LastName, FirstName, and Phone of all customers whose first name starts with B.
F.) List the LastName, FirstName, and Phone of all customers whose last name includes the characters cat.
G.) List the LastName, FirstName, and Phone for all customers whose second and third digits (from the left) of their phone number are 23. For example, any phone number with an area code of “723” would meet the criteria.
H.) Determine the maximum and minimum TotalAmount.
I.) Determine the average TotalAmount.
J.) Count the number of customers.
K.) Group customers by LastName and then by FirstName.
L.) Count the number of customers having each combination of LastName and FirstName.
M.) Show the LastName, FirstName, and Phone of all customers who have had an order with TotalAmount greater than $100.00. Use a subquery. Present the results sorted by LastName in ascending order and then FirstName in descending order.
N.) Show the LastName, FirstName, and Phone of all customers who have had an order with TotalAmount greater than $100.00. Use a join, but do not use JOIN ON syntax. Present results sorted by LastName in ascending order and then FirstName in descend-
ing order.
O.) Show the LastName, FirstName, and Phone of all customers who have had an order with TotalAmount greater than $100.00. Use a join using JOIN ON syntax. Present results sorted by LastName in ascending order and then FirstName in descending order.
P.) Show the LastName, FirstName, and Phone of all customers who have had an order with an Item named Dress Shirt. Use a subquery. Present results sorted by LastName in ascending order and then FirstName in descending order.
Q.) Show the LastName, FirstName, and Phone of all customers who have had an order with an Item named Dress Shirt. Use a join, but do not use JOIN ON syntax. Present results sorted by LastName in ascending order and then First-Name in descending order.
R.) Show the LastName, FirstName, and Phone of all customers who have had an order with an Item named Dress Shirt. Use a join using JOIN ON syntax. Present results sorted by LastName in ascending order and then FirstName in descending order.
S.) Who referred each customer to Marcias Dry Cleaning? Show columns named CustomerLastName, CustomerFirstName, ReferredByLastName, and ReferredByFirstName. Include the names of customers who were not referred by any other customer in the results of the query.
T.) Show the LastName, FirstName, and Phone of all customers who have had an order with an Item named Dress Shirt. Use a combination of a join using JOIN ON syntax and a subquery. Present results sorted by LastName in ascending order and then First-Name in descending order.
U.) Show the LastName, FirstName, Phone, and TotalAmount of all customer orders that included an Item named Dress Shirt. Also show the LastName, FirstName, and Phone of all other customers. Present results sorted by TotalAmount in ascending order, then LastName in ascending order, and then FirstName in descending order.
HINT: In Microsoft Access 2016, you will either need to use a UNION statement or a sequence of two queries to solve this because Microsoft Access disallows nesting an INNER join inside a LEFT OUTER or RIGHT OUTER join. The other DBMS products can complete this question with one query (not a UNION statement).

View File

@ -0,0 +1,68 @@
/* *** CS2-A *** */
SELECT *
FROM CUSTOMER, INVOICE, INVOICE_ITEM ii
;
/* *** CS2-B *** */
SELECT LastName, FirstName, Phone
FROM CUSTOMER
;
/* *** CS2-C *** */
SELECT LastName, FirstName, Phone
FROM CUSTOMER
WHERE FirstName LIKE 'Nikki'
;
/* *** CS2-D *** */
SELECT LastName, FirstName, Phone, DateIn, DateOut
FROM CUSTOMER, INVOICE
WHERE TotalAmount > 100
;
/* *** CS2-E *** */
SELECT LastName, FirstName, Phone
FROM CUSTOMER
WHERE FirstName LIKE 'B%'
;
/* *** CS2-F *** */
SELECT LastName, FirstName, Phone
FROM CUSTOMER
WHERE LastName LIKE '%cat%'
;
/* *** CS2-G *** */
SELECT LastName, FirstName, Phone
FROM CUSTOMER
WHERE Phone Like '_23%'
;
/* *** CS2-H *** */
/* *** CS2-I *** */
/* *** CS2-J *** */
/* *** CS2-K *** */
/* *** CS2-L *** */
/* *** CS2-M *** */
/* *** CS2-N *** */
/* *** CS2-O *** */
/* *** CS2-P *** */
/* *** CS2-Q *** */
/* *** CS2-R *** */
/* *** CS2-S *** */
/* *** CS2-T *** */
/* *** CS2-U *** */