Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING THE ADVENTUREWORKS DB: 1. In T-SQL, create a new VIEW called PersonsByCountry that displays a list of all Persons names and the country they

USING THE ADVENTUREWORKS DB:

1. In T-SQL, create a new VIEW called PersonsByCountry that displays a list of all Persons names and the country they live in.

2. Write a SELECT query to display all the data from the PersonsByCountry view, sorted by country name, persons last name, then first name.

3. In the SSMS GUI Editor, create a second VIEW, called PersonAndEmailsByCountry, based on the view from part 1, that displays all data and includes each persons email address. Note: This isnt a copy-paste-SQL job! Reference the other view in the new view, which may require you to make some changes to the original PersonsByCountry view.

4. Script your GUI-created VIEW and add the CREATE VIEW part to the T-SQL script youre writing for the other steps. (Right-click the PersonAndEmailsByCountry view, choose Script View AS... Create...)

5. Write a SELECT query to display data from the PersonAndEmailsByCountry view, for persons residing in the USA, and whose email addresses start with P, sorted by persons last name, then first name, and hiding any non-user-friendly columns of data.

6. In T-SQL, create a new view called PersonEmployees, based on the view from part 3, that displays all the person data for anyone who is an employee of the AdventureWorks company, and includes their job title and hire date.

7. Write a SELECT query to display data from the PersonEmployees view, showing the employees full name (in a single field), their job title, hire date, email address and country, for any employee hired in 2012 or later. Sort the data from most recent hire date, then by job title, then employee name. (Note: Remember that in AdventureWorks, you have to include the schema in the table name. The Employee table is in a schema called HumanResources).

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

14. State the all-or-none law.

Answered: 1 week ago

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago