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 VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
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
SQL 2016 DESIGN & PROGRAMMING
 
 
 
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