Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write SQL statements for the following questions. Please take a screenshot for each question that includes both the sql statement and the result .

Please write SQL statements for the following questions. Please take a screenshot for each question that includes both the sql statement and the result. If the result table is too long to capture, scroll down to show the last few tuples (rows). A screenshot can be taken using snipping tool which can be found under Windows start menu --> all programs --> accessories.

Once a screenshot is taken, paste it to a Word document and submit the Word file to Canvas. All screenshots should be listed in a single Word file in the order of the questions below. The submission file MUST be .doc, .docx, or .pdf file.

Q1. Write SQL statement with explicit join syntax that returns the following five columns from two tables:

Vendor_ID, vendor_id from VENDORS table

Vendor_City, vendor_city from VENDORS table

Vendor_State, vendor_state from VENDORS table

Contact_Last_Name, last_name from VENDOR_CONTACTS table

Contact_First_Name, first_name from VENDOR_CONTACTS table

Use the following aliases for the tables: V for VENDORS table and VC for VENDOR_CONTACTS table. Also sort the result set by Vendor_ID.

Q2. Rewrite the Q1 answer using implicit join syntax.

Q3. Using an explicit self-join syntax, write SQL statement that returns the following columns from EMPLOYEES table.

Emp_ID, employee_id from EMPLOYEES table

Emp_Last_Name, last_name from EMPLOYEES table

Manager_ID, manager_id from EMPLOYEES table

Manager_Name, last_name from EMPLOYEES table

The result set should have one row for each employee that shows manager id and manager name. If an employee does not have a manager, the manager information should be null.

(Note that the result still includes employees who do not have a manager.)

If there is a manager who is not listed as an employee in the employee table, the result should NOT include those managers.

Sort the result set by Emp_id.

Q4. Using the UNION operator, write SQL statement that returns a result set consisting of the following columns.

Invoice_ID, invoide_id from INVOICES table

Vendor_ID, vendor_id from INVOICES table

Credit_Total, credit_total from INVOICES table

Has_Credit. YES if the credit_total is greater than 0, otherwise NO

Sort the final result set by Credit_Total in descending order.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago