DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS  SQL 2012 PROGRAMMING  DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to list the top 5 percent?

Execute the following SQL Server T-SQL scripts in SSMS Query Editor to list the top 5 percent result set with ties and without ties:

USE AdventureWorks;

 

SELECT   TOP ( 5 ) PERCENT WITH TIES Employee = FirstName + ' ' + Lastname,

                                     e.Title,

                                     Gender,

                                     Rate

FROM     HumanResources.Employee e

         JOIN HumanResources.EmployeePayHistory eph

           ON e.EmployeeID = eph.EmployeeID

         JOIN Person.Contact c

           ON c.ContactID = E.ContactID

ORDER BY Rate DESC;

GO

-- (16 row(s) affected)

 

SELECT   TOP ( 5 ) PERCENT Employee = FirstName + ' ' + Lastname,

                           e.Title,

                           Gender,

                           Rate

FROM     HumanResources.Employee e

         JOIN HumanResources.EmployeePayHistory eph

           ON e.EmployeeID = eph.EmployeeID

         JOIN Person.Contact c

           ON c.ContactID = E.ContactID

ORDER BY Rate DESC;

GO

-- (16 row(s) affected)

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE