Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use the Small Company ERD to complete the steps listed below. Read each of the questions listed in the left column of the table
Use the Small Company ERD to complete the steps listed below. Read each of the questions listed in the left column of the table below. Write the answer to your question and/or the required SQL statement in the corresponding cell in the right column that answers the question. (Test your statement to confirm the results before submitting.) Save this document once you have added your answers and uploaded it as part of your submission. A. Using Joins (30 points) Joins a. Write a query using a join that displays employees' IDs, names, and department names. Sort your results by department and employee last name. b. Write a query using a join that displays employees' IDs, names, and job names. Sort your results by department and employee last name. c. Write a query using a join that displays employees IDs, names, job and department names. Sort your results by department, job, and employee last name. d. Write a query using a self-join to display employees IDs and names along with their manager's ID and name. Sort your results by the managers' last names and the employees' last names. e. Write a query using a join that displays customers' IDs, names, order numbers, and order dates. Sort your results by order date (descending) and customers' names. f. Write a query using a join that displays customer customers' IDs, names, order numbers, order dates, and book titles associated with the order. Sort your results by order date (descending), customers' last names, and book title. The company would like to send coupons to customers that like to read fiction. Write a query to display a list of customers that have purchased book titles that are categorized as fiction (BOOK_CATEGORY_CD= F). Your results should include the customers' name and email. It should also include the order number, date, and book title for their previous purchase of fiction book. Sort your results by the customers' last name, order date, and book title. h. The company would like to identify all of the customers that have never placed an order. Write a query using a join that provides this information. Your results should include all the customer details and the order number column. Sort your results by the customers' last name and then first name. i. The company is performing an analysis of their inventory. They are considering purging books that are not popular with their customers. To do this they need a list of books that have never been purchased. Write a query using a join that provides this information. Your results should include all the book details and the order number column. Sort your results by the book title. B. Using Set Operators (30 points) Set Operators a. The budget at the company is tight. The president is considering making cuts. He would like a report that lists people who meet the following criterion: o salary> 12500 and manager_id is not null o hire_date > to_date("1996-01-01','yyyy-mm- dd') Using the Boolean operators AND and OR produced an inaccurate report. Write a query that uses the set operator INTERSECT to produce an accurate report. b. Describe why the using Boolean operators produces different results than the set operator INTERSECT in this scenario. c. The President of the company is also a customer. Write a SQL statement that adds his customer record to the database. Give him CUSTOMER_ID 999. His address is 1999 Green Mile Lane in Los Angeles, California 90210. d. The company had a data breach and needs to contact everyone in their database - employees and customers. Write a SQL statement that uses the UNION set operator to create a list of employees and customers. Your results should include the employees and customers' first names, last names, and email addresses and be sorted by last name. e. Write a SQL statement that uses the UNION ALL set operator to create a list of employees and customers. Your results should include the employees and customers' first names, last names, and email addresses and be sorted by last name. f. Write a SQL statement that uses the INTERSECT set operator to create a list of employees and customers. Your results should include the employees and customers' first names, last names, and email addresses and be sorted by last name. - Write a SQL statement that uses the MINUS set operator to create a list of employees and customers. Your results should include the employees and customers' first names, last names, and email addresses and be sorted by last name. h. Explain the differences in your results to questions #d-g. i. Which SQL statement should you use to create the list needed to contact everyone in the database about the data breach?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started