

Right-click the Production.ProductCostHistory table, and choose “Select table as.” Select “Select to” and New Query Editor Window. In SQL Server Management Studio, expand the AdventureWorks2008 database. Be sure to use one of the features in SQL Server Management Studio to help you write this query. Write a query displaying all the columns of the Production.ProductCostHistory table from the rows that were modified on June 17, 2003. SELECT FirstName, MiddleName, LastName, BusinessEntityID FROM Person.Person WHERE MiddleName = 'J'

Display the first, last, and middle names along with the ID numbers. Write a query using a WHERE clause that displays all the names in Person.Person with the middle name J. SELECT BusinessEntityID, JobTitle, LoginID FROM HumanResources.Employee WHERE JobTitle = 'Research and Development Engineer' Display the business entity ID number, the login ID, and the title for each one. Write a query using a WHERE clause that displays all the employees listed in the HumanResources.Employee table who have the job title Research and Development Engineer. Solutions to Exercise 2-2: Filtering Data Use the AdventureWorks2008 database to complete this exercise. You can also keep users from seeing confidential information by retrieving only the columns they should see. You would do this to decrease the amount of network traffic and increase the performance of the query, retrieving only the columns needed for the application or report. SELECT CustomerID, SalesOrderID FROM SalesLT.SalesOrderHeader Īnswer this question: Why should you specify column names rather than an asterisk when writing the SELECT list? Give at least two reasons. Write a SELECT statement that lists the customer ID numbers and sales order ID numbers from the SalesLT.SalesOrderHeader table. SELECT Name, ProductNumber, Color FROM SalesLT.Product Write a SELECT statement that lists the name, product number, and color of each product. SELECT CustomerID, LastName, FirstName, CompanyName FROM SalesLT.Customer Include the last names, first names, and company names. Write a SELECT statement that lists the customers along with their ID numbers. Solutions to Exercise 2-1: Using the SELECT Statement Use the AdventureWorksLT2008 database to complete this exercise. Solutions to the Exercises The appendix provides answers to the exercise questions in Chapters 2 through 8.Ĭhapter 2: Writing Simple SELECT Queries This section provides solutions to the exercises on writing simple SELECT queries.
