Here are the answers to the questions from the lesson on Simple SELECT Queries.
Question 1
How can you find all the table names in the AdventureWorks2012 database?
The easiest way, when starting out with Microsoft SQL server, is to use SQL Server Management Studio’s object explorer to open and explore a database’s tables.
Question 2
What are two ways to get the names of all the columns in the Person.Person table?
The first way is to use the object explorer. Below is a picture on how to do this.
The second way is to use the following SQL statement:
SELECT * FROM Person.Person
Note: Though SELECT * will give you all the columns, I wouldn’t advise using it on a large database!
Question 3
Select JobTitle and BirthDate for all employees.
SELECT JobTitle, BirthDate FROM HumanResources.Employee
Question 4
What would the UnitPrice of each PurchaseOrderDetail items be if there was a half off sale?
SELECT PurchaseOrderID, PurchaseOrderDetailID, UnitPrice, UnitPrice / 2 as HalfOff From Purchasing.PurchaseOrderDetail