Question
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
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