------------------------------------------------------------------------
-- John David Ayers ----------------------------------------------------
-- September 15, 2009 --------------------------------------------------
-- SELECT COMMAND ------------------------------------------------------
------------------------------------------------------------------------

--SELECT FROM
USE SalesOrders;
SELECT EmpLastName, EmpFirstName, EmpAreaCode, EmpPhoneNumber
FROM Employees;

--SELECTS ALL
SELECT *
FROM Employees;

--SELECTS DISTINCT
SELECT DISTINCT EmpAreaCode,
FROM Employees;
SELECT DISTINCT EmpState
FROM Employees;

--ORDER BY
SELECT EmpLastName, EmpFirstName
FROM Employees
ORDER BY EmpLastName DESC/* Descending Order */, EmpFirstName;
SELECT CustLastName, CustFirstName, CustCity, CustState
FROM Customers
ORDER BY CustState, CustCity, CustLastName;

--SELECT TOP & PERCENT
SELECT TOP 10 PERCENT ProductName, RetailPrice
FROM Products
ORDER BY RetailPrice DESC;

--VIEW
CREATE VIEW EmployeePhoneListing
AS
SELECT TOP 100 PERCENT EmpLastName, EmpFirstName, EmpAreaCode, EmpPhoneNumber
FROM Employees
ORDER BY EmpLastName, EmpFirstName
GO
