Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you will be writing T-SQL statements in SSMS. Using the knowledge you gained in the Learning Team Collaborative Discussion this week, create

For this assignment you will be writing T-SQL statements in SSMS.

Using the knowledge you gained in the Learning Team Collaborative Discussion this week, create and perform the following T-SQL statements:

Create a query using INNER JOIN that will show all rows and all columns from both tables. You will join the tables using DepartmentID from the Employees table and ID from the Departments table.

Add another department to the Departments table using a T-SQL INSERT statement. Call this department 'Maintenance'. Show the results of this insert by selecting all rows and all columns from the Departments table.

Add a row to the Employees table by adding the data specified in the Week Four tab of data within the Sample Data Excel spreadsheet. Make sure that the Department ID you use for this is NOT a valid Department ID from the Departments table (we are on purpose creating an 'orphan' record.

Create a T-SQL Query using OUTER JOIN to list all Employees that do not have a valid department assignment. (Hint: WHERE Departments.ID IS NULL)

Create a T-SQL Query using OUTER JOIN to list all Departments that have no employees. (Hint: WHERE Employees.ID IS NULL)

Create a T-SQL select statement that will use an INNER JOIN to pull data from both tables based on Departments.ID and Employees.DepartmentID. Return all rows where these columns match. Only show the following columns: DepartmentName, LastName, FirstName, AnnualSalary, and StartDate (in that order).

Based on the query you created in the previous step, create a View called viewDepartmentEmployees. Create a T-SQL statement to use the View.

Using viewDepartmentEmployees, create T-SQL that will order the view results by DepartmentName. Do not modify the view to do this.

Using viewDepartmentEmployees, create T-SQL that will order the view results by Employee LastName. Do not modify the view to do this.

Using viewDepartmentEmployees, create T-SQL that will return only those employees with salaries > $100,000. (Hint: Use a WHERE clause). Do not modify the view to do this.

Below is the information to be added for this assignement:

**Department table, Name: Maintanence, Description: Maintanence Department

**Employees table, LastName:Hansen, FIrstName:Larry MiddleName:____,StartDate:04/01/2017,AnnualSalary:$156,000

The structure and data of the department and employees have not been provided. Create tables with minimum required data and disregard information supplied.

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_2

Step: 3

blur-text-image_3

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

1. Evaluate the training program in which Benno was enrolled.

Answered: 1 week ago

Question

Buddy Dog Foods management to change its focus?

Answered: 1 week ago

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago