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 apply the TOP clause with UPDATE?

Execute the following Microsoft SQL Server T-SQL script to give a 10% raise to the lowest paid staff in the fictional mountain bike factory:

-- The following query is based on a previous version of AdventureWorks

USE AdventureWorks

-- T-SQL UPDATE statement with TOP filtering

-- SQL INNER JOIN with SELECT subquery (subselect)

UPDATE a

SET    BaseRate = 1.1 * BaseRate

FROM   HumanResources.Employee a

  INNER JOIN 

       (SELECT   TOP ( 10 ) PERCENT WITH TIES EmployeeID

        FROM     HumanResources.Employee

        ORDER BY BaseRate DESC) b

     ON   a.EmployeeID = b.EmployeeID

 

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